This issue has been created
There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-f2c1ec61-1773-4adb-84fa-4d9a424af3f8 XWIKI-22403 Open

WYSIWYG deletes typed text due to fake selection

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-d92fe86a-f926-4b97-a40f-2611a6aec130 Nikita Petrenko created this issue on 08/Aug/24 10:28
 
Summary: WYSIWYG deletes typed text due to fake selection
Issue Type: cid:jira-generated-image-avatar-f2c1ec61-1773-4adb-84fa-4d9a424af3f8 Bug
Affects Versions: 15.10.11
Assignee: Unassigned
Components: WYSIWYG Editor
Created: 08/Aug/24 10:28
Environment: W10, MS Edge 127, XWiki 15.10.11
Priority: cid:jira-generated-image-static-major-b3a67b55-fc3b-425c-880e-2975722d1379 Major
Reporter: Nikita Petrenko
Description:

Prerequisites:

  • XWiki 15.10.11
  • Any supported web-browser latest version (MS Edge, GG, Firefox)
  • Being logged as XWiki Admin

Steps to reproduce:

  1. Navigate to any Sandbox test page and trigger in-line editing
  2. Create an empty table either from QA (quick action) or from the CKEditor toolbar icon with the default size
  3. Fill the first cell in the first row with one-line text or doubled line text as you prefer
  4. Trigger context menu on changed cell Row → Insert row before
  5. Either move the cursor into an inserted row (before) or next row (after), and type any text or word, in the end press backspace button

Actual result

The text you put before will be deleted, although backspace was not clicked on that cell/row.

Expected result

The text of the previous cell is not deleted.

Note

I don't reproduce the error in CKEditor 4 demo.

 
 

1 comment

 
cid:jira-generated-image-avatar-d92fe86a-f926-4b97-a40f-2611a6aec130 Nikita Petrenko on 08/Aug/24 10:31
 

Thanks to Marius Dumitru Florea for an explanation of this issue

This is what happens:

  • CKEditor supports a real selection (e.g. the caret used to type text or when you select some text) and a fake selection (e.g. when you select some cells or rows from a table, and you see the blue background)
  • the fake selection has priority, meaning that when a fake selection is set, it gets returned even if there is also a real selection
    * the fake selection is normally cleared by various actions performed in the editor (e.g. click, press Enter, etc.)

  • after you insert a new table row (below) in your test case, the first row/cell gets selected (and this is a fake selection). You can see the blue background.
  • even though you click on the cell below and you start typing (and the blue background disappears), for some reason the fake selection is not cleared
  • when you press Delete, it acts on the fake selection instead of the real selection, and thus it deletes the content from the cells included in the fake selection.

The difference between our editor and the CKEditor 4 demo is that the fake selection is cleared when you click on the cell bellow. I tried to understand why but I failed. Note that our editor has a single listener for Delete key but it's not even called (because CKEditor's listener for fake selection cancels the event). So the problem is in the core CKEditor, but it's not easy to debug selection problems because you can't do step by step debugging because the selection changes once the focus is lost..