Skip to content
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

CKEditor 4 - Selecting whole content by pressing Control + A & press Delete on Keyboard doesn’t erase all bullet points On first try #4931

Closed
sridharravva opened this issue Oct 14, 2021 · 10 comments · Fixed by #5291
Assignees
Labels
plugin:widgetselection The plugin which probably causes the issue. status:confirmed An issue confirmed by the development team. type:bug A bug.
Milestone

Comments

@sridharravva
Copy link

Hi,
I have tried this using CKEditor 4 - Standard Package Version 4.16.1 and Standard Package Version 4.16.2 and found this bug on Chrome browser. Basically, under Chrome browser, when I am selecting whole content in CKEditor by pressing Control + A & press Delete on Keyboard then it doesn’t erase all bullet points On first try. We could delete whole content present on CKEditor in multiple attempts and not in one single attempt. It looks like there is some bug with this CKEditor control only in Chrome browser since it works fine on Firefox browser, no issue with that FF browser.
Can someone please advice how to resolve this issue on Chrome browser? Thanks!

Here it is sample content that I tried erasing it on CKEditor 4 control by pressing Control + A and then Press Delete button on Keyboard

image

@sridharravva sridharravva added the type:bug A bug. label Oct 14, 2021
@KarolDawidziuk
Copy link
Contributor

Hi, @sridharravva
Thank you for the report.
For me, everything looks okay. I created a similar content as you provide but it works (tested on both versions).

Could you give more information? like:
OS:
Installed CKEditor plugins:
Chrome version:

@sridharravva
Copy link
Author

sridharravva commented Oct 14, 2021

Hi, @sridharravva Thank you for the report. For me, everything looks okay. I created a similar content as you provide but it works (tested on both versions).

Could you give more information? like: OS: Installed CKEditor plugins: Chrome version:

I have tried with the CKEditor 4.16.1 Standard package with above bulleted content on Windows 10 machine and Chrome browser.
Basically, under Chrome browser, when try selecting whole content in CKEditor by pressing Control + A & then press Delete on Keyboard then you can see, it won't let you erase all bullet points On single first try. We could only delete whole content present on CKEditor in multiple attempts and not in one single attempt.
I see the same issue with Edge browser as well.
Installed plugins are font, wordcount, pastetools and clipboard and few other plugins that came as part of standard package of CKEditor 4.16.1.
Please let me know how to resolve this issue erasing all bulleted content in CKEditor in single try and not in multiple tries.
Here it is the complete list of plugins that I have it for CKEditor 4.16.1:
image

@KarolDawidziuk
Copy link
Contributor

KarolDawidziuk commented Oct 18, 2021

Hi, @sridharravva
Thank you for more details.

I can confirm this issue.
In conclusion. This problem occurred on

  • OS: Win10(tested on VBox)
  • Browsers: Chrome/Edge/IE
  • Firefox and browsers on macOS work properly
Screen.Recording.2021-10-16.mov

@KarolDawidziuk KarolDawidziuk added status:confirmed An issue confirmed by the development team. browser:chrome The issue can only be reproduced in the Chrome browser. size:? and removed browser:chrome The issue can only be reproduced in the Chrome browser. labels Oct 18, 2021
@sculpt0r
Copy link
Contributor

sculpt0r commented Dec 7, 2021

Probably fixed in #4943 - to verify

@KarolDawidziuk
Copy link
Contributor

Unfortunately, #4943 didn't fix it.
It's looking like a selection problem on Windows.

@KarolDawidziuk KarolDawidziuk removed their assignment Dec 13, 2021
@sculpt0r sculpt0r self-assigned this Jun 9, 2022
@sculpt0r
Copy link
Contributor

sculpt0r commented Jun 22, 2022

For now - it looks like a selection problem (not a problem with deleting list items) - only when the last element in list is empty. Reproducible even with small source sample:

<ol>
	<li>1</li>
	<li>&nbsp;</li>
</ol>

If you put anything instead of nbsp - the selection looks fine. But with the nbsp - it 'skips' the last element 🤔

The selection is fine if I use the "Select all" plugin - so the entire list is deleted.

If I remove widgetselection (and all plugins that requires it) - the issue is also reproducible on macOS:

	removePlugins: 'uploadimage, uploadwidget, widget, widgetselection'

With Cmd/Ctrl + A and removed plugins: the selection behaves the same on both OS.

On macOS - events logs in widgetselection:
image

but on Win10 - there is one event missed:
image

@sculpt0r sculpt0r added the plugin:widgetselection The plugin which probably causes the issue. label Jun 23, 2022
@sculpt0r
Copy link
Contributor

sculpt0r commented Jun 23, 2022

Also, we have a comment:

* @fileOverview A plugin created to handle ticket https://dev.ckeditor.com/ticket/11064. While the issue is caused by native WebKit/Blink behaviour,
* this plugin can be easily detached or modified when the issue is fixed in the browsers without changing the core.
* When Ctrl/Cmd + A is pressed to select all content it does not work due to a bug in
* Webkit/Blink if a non-editable element is at the beginning or the end of the content.

And then, this method behaves differently on Win10:

isWholeContentSelected: function( editable ) {

in the return statement:

rangeClone.startOffset === 0 && rangeClone.endOffset === editable.getChildCount() &&

on Win10 - the rangeClone.endOffset is equal to 0 whereas on macOS - it is 1 - so the entire method returns different boolean and fixes are not applied on Win10

The editor behaves differently on debugger than in casual...

@sculpt0r
Copy link
Contributor

sculpt0r commented Jun 23, 2022

I switched to testing this behavior with logs - since debugging step-by-step produce unpredictable results 🤔

Method mentioned before

isWholeContentSelected: function( editable ) {

returns false on macOS and true on Win10. Because of that - additional filters are not applied (on Win10) after the if statement:

if ( !this.isWholeContentSelected( editable ) && editable.getChildCount() > 0 ) {

on macOS the functions early return false, because the range is collapsed:

if ( range && range.collapsed ) {
return false;

but on Win10 the range is not collapsed - so the functions go to the big return statement which evaluates to true:

return !!( rangeClone && editable && rangeClone.startContainer && rangeClone.endContainer &&
rangeClone.startOffset === 0 && rangeClone.endOffset === editable.getChildCount() &&
rangeClone.startContainer.equals( editable ) && rangeClone.endContainer.equals( editable ) );

According to spec the collapsed value is based on the selection anchor and focus properties. Based on my logs, we have different values in the native selection object (between the OS):
on macOS: anchorNode and focusNode are the same (both are the text):
image
but on Win10 - they are not:

image

The text from macOS selection are the additional filter applied by widgetselection plugin:
image

@sculpt0r
Copy link
Contributor

All unit tests are passing on Chrome Win10 under tags:

  • widgetselection
  • selection
  • range
  • selectAll

@CKEditorBot
Copy link
Collaborator

Closed in #5291

@CKEditorBot CKEditorBot added this to the 4.20.0 milestone Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin:widgetselection The plugin which probably causes the issue. status:confirmed An issue confirmed by the development team. type:bug A bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants