-
Notifications
You must be signed in to change notification settings - Fork 7
Handle 'Backspace' block elements removal on Android #165
Conversation
I have also added |
Does this patch is somehow targetted at Android? Or will it handle mutations on all browsers? I'm curious if this may help us with some other potential issues where we're not able to handle some changes. But I'm also worried if it might handle too much. @Mgsy, could you test this PR? Ideally, on Android, but also on some desktop browser to see that there are no collisions. We're interested in all typing related scenarios – not only backspace, but also enter and simple typing. I'm curious about the general status of things on Android. |
There is no environment/device detection so it will be fired on all devices/browsers. However, it handles very specific cases so it shouldn't interfere with the current flow for other browsers (and if such case will happen it will be handled same as on Android which seems to make sense as it will provide consistent behaviour). Of course there always may be some strange/edge cases... So if something gets removed unexpectedly (not only on Backspace, but in general), it means it might be caused by this fix (cc @Mgsy). Two issues which are likely to be encounter while testing this PR - https://github.com/ckeditor/ckeditor5-typing/issues/166, ckeditor/ckeditor5#1127. |
AndroidSteps to reproduce
Current resultThe whole block is removed and the selection moves to the previous block. Expected resultOnly word |
AndroidSteps to reproduce
Current resultNothing happens. Expected resultThe paragraph is merged to the previous block. NotesIt requires 8x backspace to merge the blocks. |
Ouch... That's the inline filler. Nothing blocking for this PR but we'll need to figure out how to get rid of it. |
AndroidSteps to reproduce
Current result
|
It might be related to https://github.com/ckeditor/ckeditor5-typing/issues/160, where reference to inline filler is lost, I will check it. |
I've tested it in all desktop browsers and didn't notice any bugs related to this change. On Android also works good, except cases mentioned above 👌 |
It looks like Android is a rather tricky environment 😭 I'm able to reproduce all three issues on the current First issue - #165 (comment):It happens randomly with and without this PR. There are basically two different flows - one results in correct paragraph removal (so empty paragraph is left) and the other one in entire paragraph removal. Correct flow:
Incorrect flow:
So it seems the problem is related to unstable selection which is different for identical set of operations, this might be the same problem as ckeditor/ckeditor5#1127. The other thing is that maybe adjusting how |
Second issue - #165 (comment):This is related to #160 - after last step (pressing Backsace), the In this scenario the above fix is not triggered at all because merging lines is handled natively. 🤔 |
Third issue - #165 (comment):This is the same case as ckeditor/ckeditor5#1127. Selection sometimes is collapse, sometimes not which triggers removing selected content by The Android mutations handler added in this PR is not triggered in the invalid case (non-collapsed selection) at all. |
Suggested merge commit message (convention)
Type: Handle
Backspace
block elements removal on Android. Closes ckeditor/ckeditor5/issues/1106. Closes ckeditor/ckeditor5/issues/1130.Additional information
The main issues with the Backsapce on Android are described in ckeditor/ckeditor5#614 (comment) and ckeditor/ckeditor5#614 (comment) and they are the main reason why the solution is implemented in a way it is (of course apart from the fact that every key press has
229
key code on Android).To sum up how the flow looks like in a general perspective:
injectAndroidBackspaceMutationsHandling
is initialised insideDelete
plugin.selection
change andmutations
listener:selection
change listener stores previous and current selection every time it changes, it also stores timestamp of the latest changemutations
listener checks if given mutations are the block removal mutations and acts accordinglyThere is also one unrelated but similar issue - ckeditor/ckeditor5#1127