Cursor moves to the previous cell inside table on pressing BACKSPACE after removing text.
Type of Report
Bug
Reproduction Steps
https://ckeditor.com/latest/samples/
- Fill in both columns with some text.
- Click on the first cell then press the TAB. (Next cell will turn blue)
- Now press BACKSPACE to remove the text inside this cell.
- Observe the cursor.
Please see the attached gif.

Expected Result
The cursor should stay in the same cell after removing text
Actual Result
The cursor moves to the previous cell.
Other Details
- Browser: Version 91.0.4472.164 (Official Build) (64-bit)
- OS: Windows 10 Version 1090 (OS Build 18363.836)
- CKEditor version: 14.14.1
- Installed CKEditor plugins: table, tableselection, tab
Note
The issue occurred after integrating TAB plugin
Hi @usmannoor10p,
Thank you for the report. I can confirm this issue. It is reproducible at 4.16.1 and even back in 4.13.0 so I assume it is this kind of bug 🐛 which exists from the beginning.
I tried the following browsers: Safari, Chrome, and Firefox.
Hi @usmannoor10p, Thank you for the report. I can confirm this issue. It is reproducible at
4.16.1and even back in4.13.0so I assume it is this kind of bug 🐛 which exists from the beginning.I tried the following browsers: Safari, Chrome, and Firefox.
Hi @sculpt0r ,
Thanks for the acknowledgment. So should I wait for the fix or is there any other workaround available?
Please do let me know. Thanks
Hi @usmannoor10p, For now, you should wait for the fix, but I can't guarantee any ETA here. However, if you have CKEditor license, please contact our support team.
Sure @sculpt0r , thanks for the update. I will wait for the fix then.
I've done some research on it.
The logic in the tableselection plugin removes the content from the selected cell and then attempts to remove an empty table fragment (which is needed to detect cases like selecting and deleting the whole row) → https://github.com/ckeditor/ckeditor4/blob/19a386c4691a99d37b43e876e5f5a7ce092c6016/plugins/tableselection/plugin.js#L1090-L1094
The deleteEmptyTablePart() function returns a new range for selection (which is understandable – after all, it removes the element in which the selection is anchored). It uses the CKEDITOR.dom.range#getBoundaryNodes() method → https://github.com/ckeditor/ckeditor4/blob/19a386c4691a99d37b43e876e5f5a7ce092c6016/plugins/tableselection/plugin.js#L998
However, CKEDITOR.dom.range#getBoundaryNodes() method returns a previous element to the current one if the current one does not have any children → https://github.com/ckeditor/ckeditor4/blob/19a386c4691a99d37b43e876e5f5a7ce092c6016/core/dom/range.js#L1077-L1078
The table cell after its content is removed is empty, so the CKEDITOR.dom.range#getBoundaryNodes() points to the previous cell and due to that the deleteEmptyTablePart() function returns a collapsed selection in the previous cell.
Probably the deleteEmptyTablePart() function should return nothing in case of not removing anything from the table. That would preserve the original range and fix the issue.
Closed in https://github.com/ckeditor/ckeditor4/pull/5349