-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FF] Focusing in image caption using tab key messes up selection handling #4188
Comments
Also it is impossible to focus image afters step 4. |
The same also happens sometimes after you do some undoes, but very rarely and I haven't yet understood when. |
Yep, I stumbled upon this too. Pretty serious because the editor is dead after that. I'm afraid, though, that this is Firefox's native issue. Could you research it @scofalik or @szymonkups and report to Mozilla if I'm right? |
I'll try and research this issue. |
In this scenario, after the Tab key is used, we (for some reason) want to set the DOM selection to the place where it was before pressing Tab. I don't know why yet, but such is view selection. I'd suspect that the view selection would be in caption, but it is what it is. Basically, the error boils down to this: https://jsfiddle.net/b6ef60aw/ . After launching the Fiddle, put the selection inside nested editable (at "Xyz"). After 5 seconds browser will try to move the selection and error will be thrown to the console. This works fine in Chrome but throws in Firefox. For some reason Firefox throws when selection is in nested editable and it is moved by code to the outer editable. PS. Removing all ranges from selection does not help. |
Could you check in ckeditor-dev for some comments about that? I think I stumbled upon this in the past. And this might already be reported to Mozilla (you can look for the issue or report one). |
I am digging more into this why view selection is not correct. It seems that problem lies here: document.on( 'focus', () => {
document.isFocused = true;
// Unfortunately native `selectionchange` event is fired asynchronously.
// We need to wait until `SelectionObserver` handle the event and then render. Otherwise rendering will
// overwrite new DOM selection with selection from the view.
// See https://github.com/ckeditor/ckeditor5-engine/issues/795 for more details.
this._renderTimeoutId = setTimeout( () => document.render(), 0 );
} ); It looks like |
It makes sense. Focus is often asynchronous and slow. In CKE4 in a similar place we had a timeout of 200ms IIRC. However, let's have the lowest stable value here. If PS. I recommend testing on a machine which is slowed down by some other task. E.g. think – building documentation :D |
I want to propose a different solution. Pushed to branch ckeditor/ckeditor5-engine@2d70a8b Instead of trying to guess and kick in at the right moment, let's force re-rendering after Please guys take a look at it and see if there is something dangerous in this solution. /cc @szymonkups @pjasiun @Reinmar PS. It seems it solve this and related issues. |
Well, we've been talking about forcing rerender after every selection change :D Maybe it's time? https://github.com/ckeditor/ckeditor5-engine/issues/796 |
My concern is mostly about scenario where |
Fix: Added a 50ms timeout after `Document#focus` event before rendering to be sure that selection changes are processed on Firefox and Safari. Closes ckeditor/ckeditor5#676. Closes #1157. Closes #1155. Closes #1153.
Steps to reproduce
NS_ERROR_FAILURE
.This is the simplest scenario, but you can observe some interesting things. After step 8, focus in any paragraph and use Bullet List feature. Instead of that paragraph, the first item in the list is changed to bullet list (or un-listed if it was bulleted list). Also the button in toolbar is "active" all the time, so I guess that selection in model is stuck in the list item. But why it did not changed after using mouse key or arrow keys?
The text was updated successfully, but these errors were encountered: