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

Improve selection with widgetselection plugin when widget is partially selected #2866

Closed
wants to merge 30 commits into from

Conversation

engineering-this
Copy link
Contributor

@engineering-this engineering-this commented Feb 26, 2019

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.

This PR contains

  • Unit tests
  • Manual tests

What changes did you make?

I've added logic to fix selection when widget is partially selected in widgetselection plugin.
However when selection is changed when user is creating one with mouse down some issues occur in Safari, so selectionChange listener is used only for other ways of selecting than mouse. When selection is made by mouse it will be fixed once button is released.

Additionally there was an an error thrown by range.deleteContents which was visible with IE11 selection. Improved if check to prevent error.

Closes #2517
Closes #3007
Closes #3008
Closes #3041

Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selection becomes corrupted after the fix.

  1. Insert new image using procedure in manual test.
  2. Try to select all using Cmd + A.

Expected:

Editor's content becomes selected.

Actual:

Editor's content becomes unselected after releasing keys.

What's interesting, after switching to source mode and back to WYSIWYG one selection works correctly.

@@ -0,0 +1,18 @@
@bender-tags: 4.11.4, bug
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add issue reference.

@engineering-this
Copy link
Contributor Author

Fixed above by further improvements to selection.

@engineering-this engineering-this changed the title Fixed: Error thrown when inserting widgets from dialog Fix for: Error thrown when inserting widgets from dialog Mar 1, 2019
@Comandeer
Copy link
Member

Updated onto latest master.

Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix is not working in Firefox:

19:51:23.825 TypeError: startNode is null[Więcej informacji] range.js:1920:4
	setStart http://tests.ckeditor.test:1030/apps/ckeditor/core/dom/range.js:1920
	setStartBefore http://tests.ckeditor.test:1030/apps/ckeditor/core/dom/range.js:1988
	fake http://tests.ckeditor.test:1030/apps/ckeditor/core/selection.js:2261
	focus http://tests.ckeditor.test:1030/apps/ckeditor/plugins/widget/plugin.js:1426
	finalizeCreation http://tests.ckeditor.test:1030/apps/ckeditor/plugins/widget/plugin.js:451
	finalizeCreation http://tests.ckeditor.test:1030/apps/ckeditor/plugins/widget/plugin.js:2059
	1 http://tests.ckeditor.test:1030/apps/ckeditor/core/event.js:202
	listenerFirer http://tests.ckeditor.test:1030/apps/ckeditor/core/event.js:144
	fire http://tests.ckeditor.test:1030/apps/ckeditor/core/event.js:290
	onClick http://tests.ckeditor.test:1030/apps/ckeditor/plugins/dialog/plugin.js:1621
	onClick http://tests.ckeditor.test:1030/apps/ckeditor/plugins/dialogui/plugin.js:964
	listenerFirer http://tests.ckeditor.test:1030/apps/ckeditor/core/event.js:144
	fire http://tests.ckeditor.test:1030/apps/ckeditor/core/event.js:290
	click http://tests.ckeditor.test:1030/apps/ckeditor/plugins/dialogui/plugin.js:916
	setTimeout http://tests.ckeditor.test:1030/apps/ckeditor/core/tools.js:578

Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that the current behaviour is valid 🤔. In Firefox the widget is visibly also selected, but after inserting widget, it appears after the existing one – yet it should have overwritten it.

OTOH behaviour in Chrome seems to be correct, as there widget isn't selected. In Safari inserting widget into such selection isn't even possible… See #3008.

See also #3007 for very similar issue, but with delete/typing.


var widget = this.getByElement( wrapper );
// Fire postponed #ready event.
widget.ready = true;
widget.fire( 'ready' );
widget.focus();
}

/**

This comment was marked as outdated.

* @returns {CKEDITOR.dom.node/null} Closest non editable ancestor which is direct child of editable element otherwise `null`.
*/
function findOuterNonEditableAncestor( node ) {
var parents = node.getParents().reverse(),

This comment was marked as outdated.

@engineering-this
Copy link
Contributor Author

Rebased on major and reworked solution, see updated description.

@f1ames f1ames added this to the 4.12.1 milestone Jun 18, 2019
@f1ames f1ames modified the milestones: 4.12.1, 4.13.0 Jun 26, 2019
@Comandeer Comandeer assigned Comandeer and unassigned Comandeer Aug 16, 2019
@f1ames f1ames modified the milestones: 4.13.0, Next Aug 22, 2019
@f1ames f1ames modified the milestones: Next, Backlog Sep 25, 2019
@f1ames f1ames closed this Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants