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

Can't get selected widgets during copy/cut after selecting all content #3352

Closed
Comandeer opened this issue Aug 25, 2019 · 6 comments
Closed
Assignees
Labels
plugin:widget The plugin which probably causes the issue. status:confirmed An issue confirmed by the development team. type:bug A bug.
Milestone

Comments

@Comandeer
Copy link
Member

Type of report

Bug

Provide detailed reproduction steps (if any)

  1. Open https://jsfiddle.net/Comandeer/ab3dsngr/
  2. Open console.
  3. Select all content inside the editor using Ctrl/Cmd + A
  4. Copy/cut content

Expected result

The array of two selected widgets should be logged into the console.

Actual result

An empty array is logged.

Other details

Strangely enough, adding selectall plugin seems to fix the issue 🤔

  • CKEditor version: 4.5.0+
  • Installed CKEditor plugins: widget
@Comandeer Comandeer added type:bug A bug. status:confirmed An issue confirmed by the development team. plugin:widget The plugin which probably causes the issue. labels Aug 25, 2019
@f1ames f1ames added this to the Next milestone Sep 6, 2019
@Comandeer Comandeer self-assigned this Sep 9, 2019
@f1ames
Copy link
Contributor

f1ames commented Sep 9, 2019

@Comandeer I see it works fine on Chrome (tested on provided JSFiddle), but fails on Firefox, which means it is browser specific issue. Can you confirm? (Chrome - 76.0.3809.132 , FF - 69.0).

@f1ames
Copy link
Contributor

f1ames commented Sep 9, 2019

It's a little more complex - select all + copy works as expected on Chrome. But selecting widget then cutting it and then select all + copy returns empty widgets array 🤔 So on FF it simply fails for every copy while on Chrome it starts to fail after cutting widget 🤔

@Comandeer
Copy link
Member Author

It's even more complex: it sometimes Just Works™ 😂 The behaviour seems to be totally random.

@f1ames f1ames added the target:minor Any docs related issue that can be merged into a master or major branch. label Sep 26, 2019
@Comandeer
Copy link
Member Author

OK, I discovered the pattern: selection is refreshed after releasing keys, so pressing Cmd/Ctrl+A and then immediately (without releasing Cmd/Ctrl key) Cmd/Ctrl+C/X shows 0 widgets. Also holding Cmd/Ctrl+A shows 0 until keys are released. It seems like more fundamental issue with refreshing selection in the editor/widget plugin.

@Comandeer
Copy link
Member Author

The very naive solution would be to fire selectionCheck also on keydown/key event:

ckeditor4/core/selection.js

Lines 934 to 940 in 5fa2a5b

// We check the selection change:
// 1. Upon "selectionchange" event from the editable element. (which might be faked event fired by our code)
// 2. After the accomplish of keyboard, mouse and touch (#2276) events.
editable.attachListener( editable, 'selectionchange', checkSelectionChange, editor );
editable.attachListener( editable, 'keyup', checkSelectionChangeTimeout, editor );
editable.attachListener( editable, 'touchstart', checkSelectionChangeTimeout, editor );
editable.attachListener( editable, 'touchend', checkSelectionChangeTimeout, editor );

However it seems to fix the issue only in Firefox, Chrome and Safari still incorrectly show the amount of selected widgets. I'm also not sure if such approach won't break anything inside the editor.

For now I can think only of more dirty solution: force widget repository to check if widgets are selected also on key event.

@f1ames f1ames removed the target:minor Any docs related issue that can be merged into a master or major branch. label Nov 12, 2019
@f1ames
Copy link
Contributor

f1ames commented Nov 29, 2019

Fixed in 6000049.

@f1ames f1ames closed this as completed Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin:widget The plugin which probably causes the issue. status:confirmed An issue confirmed by the development team. type:bug A bug.
Projects
None yet
Development

No branches or pull requests

2 participants