Opened 9 years ago
Closed 8 years ago
#14714 closed Bug (fixed)
[Webkit/Blink] Exception thrown on refocusing blurred inline editor
Reported by: | Jakub Ś | Owned by: | Marek Lewandowski |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.7.0 |
Component: | General | Version: | 4.0 |
Keywords: | Blink | Cc: |
Description (last modified by )
Steps to reproduce
- Open div area sample.
- Clear up the editor content.
- Put the selection inside the editor.
- Select "Marker" style from a styles dropdown and type some text.
- Blur the editor (by clicking outside of the editor).
- Click on styles button.
- Blur the editor (by clicking outside of the editor).
- Click on styles button.
Expected result
No JS error is thrown
Actual result
JS error is thrown:
Uncaught DOMException: Failed to execute 'setStart' on 'Range': The offset 13 is larger than or equal to the node's length (6).
Other details (browser, OS, CKEditor version, installed plugins)
Attachments (1)
Change History (18)
Changed 9 years ago by
Attachment: | 2016-07-01_1853.swf added |
---|
comment:1 Changed 9 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 9 years ago by
It does not necessarily require you to change tabs. Here'se a simplified TC:
Open div area sample.Clear up the editor content.Put the selection inside the editor.Select "Marker" style from a styles dropdown.Blur the editor (by clicking outside of the editor).Click on styles button and apply "Big" style.
Edit: Above is no longer reproducible on 4.7.0.
comment:3 follow-up: 4 Changed 8 years ago by
The error is thrown when unlocking a selection. The locked one has much higher offsets than the number of typed letters which means that it's a problem with the filling chars. The selection is locked in a DOM with a filling chars, but when it's unlocked, there are no filling chars.
I'm curious how the filling chars behave in other cases. First of all, it's obvious that all this works fine in an iframed editor because there's no selection locking as iframe can keep its own selection. But can we find some cases with inline editables in which unlocking selection works if the selection had filling chars upon lock?
comment:4 Changed 8 years ago by
Replying to Reinmar:
The error is thrown when unlocking a selection. The locked one has much higher offsets than the number of typed letters which means that it's a problem with the filling chars. The selection is locked in a DOM with a filling chars, but when it's unlocked, there are no filling chars.
It looks like the filling char sequence is removed on editor refocus. The selectionChange
event is fired after refocusing and it starts the process of checking and removing filling chars (https://github.com/ckeditor/ckeditor-dev/blob/master/core/selection.js#L859).
comment:5 Changed 8 years ago by
Any idea how it works in e.g. tab
, and then shift+tab
case that it doesn't throw? How is this case different from other ones?
comment:6 Changed 8 years ago by
I'm still looking into where is the difference between refocusing with tab
/shift+tab
and mouse (via dropdown). It works well with tab
/shift+tab
and also when focusing toolbar (alt+F10
) and applying "Big" style using keyboard.
The one strange case is when focusing toolbar (alt+F10
) and then using left
/right
arrows. It should switch between buttons in a toolbar group but instead, focus is set back in the editable area and the above exception is thrown (it happens only in the case which will throw this error ofc). The left
/right
arrow triggers removeFillingCharSequenceNode
function which causes this error.
comment:7 Changed 8 years ago by
It can also be reproduced following the steps:
- Open div area sample.
- Clear up the editor content.
- Put the selection inside the editor.
- Select "Marker" style from a styles dropdown and type some text.
- Blur the editor (by clicking outside of the editor).
- Click on styles button.
- Blur the editor (by clicking outside of the editor).
- Click on styles button.
It seems like at the first refocus (step 6), removeFillingCharSequenceNode
method (which removes filling chars) runs without any error and ranges cache is updated with the proper range. However, after refocusing for the second time (step 8), selection unlocking uses the previous range (with offset involving filling char sequence).
comment:8 Changed 8 years ago by
Milestone: | → CKEditor 4.7.0 |
---|
comment:9 Changed 8 years ago by
While checking one solution to this bug I found another one, that's not related by code, but definitely related from the user's perspective: http://dev.ckeditor.com/ticket/16895#ticket
comment:10 Changed 8 years ago by
Owner: | set to Tade0 |
---|---|
Status: | confirmed → review |
Cherry-picked the changes made by k.krzton
on top of major
, updated tags.
Changes pushed to branch:t/14714.
comment:11 Changed 8 years ago by
Status: | review → assigned |
---|
comment:12 Changed 8 years ago by
Status: | assigned → review |
---|
Added unit tests.
Changes pushed to branch:t/14714.
comment:14 Changed 8 years ago by
Owner: | changed from Tade0 to Marek Lewandowski |
---|---|
Status: | review_failed → assigned |
I'll take over this issue.
comment:16 Changed 8 years ago by
Description: | modified (diff) |
---|---|
Summary: | Divarea - changing tabs and applying styles throws JS error → [Webkit/Blink] Exception thrown on refocusing blurred inline editor |
Changed reproduce steps in the summary - the former involved some redundant steps. Adding original TC below:
Steps to reproduce
- Open two tabs in Chrome or Opera
- Open divarea sample and clear editor contents.
- Type text, select
Big
from styles dropdown, type more text, selectSmall
and type more text - Click on another tab, click on tab with editor and select e.g.
Typewriter
style from dropdown.
Expected result
No JS error is thrown
Actual result
Code: selection.js Line: 1921 Message: Uncaught IndexSizeError: Failed to execute 'setStart' on 'Range': The offset 22 is larger than or equal to the node's length (15). Code: style.js Line: 331 Message: Uncaught TypeError: Cannot read property 'elements' of null
comment:17 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed with git:e0e0043f5c.
Please also see the video showing the issue.