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

Do not render DOM selection when events happens inside UIElement #4465

Closed
jodator opened this issue Jan 18, 2019 · 3 comments
Closed

Do not render DOM selection when events happens inside UIElement #4465

jodator opened this issue Jan 18, 2019 · 3 comments
Labels
package:engine support:3 An issue reported by a commercially licensed client. type:improvement This issue reports a possible enhancement of an existing feature.

Comments

@jodator
Copy link
Contributor

jodator commented Jan 18, 2019

The remaining problem with widget is that you cannot click inside them. It seems that the issue with selection boils down to the fact that selection is always rendered. I've created a hack that stops selection rendering when events: focus, mousedown, click, keydown (TAB navigation) occurs on elements inside UIElement:

function preventCKEditorHandling( domElement, editor ) {
	// Prevent the editor from listening on below events in order to stop rendering selection.
	domElement.addEventListener( 'click', stopEventPropagationAndHackRendererFocus, { capture: true } );
	domElement.addEventListener( 'mousedown', stopEventPropagationAndHackRendererFocus, { capture: true } );
	domElement.addEventListener( 'focus', stopEventPropagationAndHackRendererFocus, { capture: true } );

	// Prevents TAB handling or other editor keys listeners which might be executed on editors selection.
	domElement.addEventListener( 'keydown', stopEventPropagationAndHackRendererFocus, { capture: true } );

	function stopEventPropagationAndHackRendererFocus( evt ) {
		evt.stopPropagation();
		// This prevents rendering changed view selection thus preventing to changing DOM selection while inside a widget.
		editor.editing.view._renderer.isFocused = false;
	}
}

This is rather dumb fix and requires knowing of renderer internals but the fix should include similar logic: do not render DOM selection when those events are triggered on node inside UIElement.

@pjasiun
Copy link

pjasiun commented Jan 18, 2019

Agree, that's just a bug we should fix in the renderer. UI element should allow you to handle focus inside it any way you want.

@mlewand mlewand transferred this issue from ckeditor/ckeditor5-engine Oct 9, 2019
@mlewand mlewand added this to the backlog milestone Oct 9, 2019
@mlewand mlewand added module:selection type:improvement This issue reports a possible enhancement of an existing feature. package:engine labels Oct 9, 2019
@lslowikowska lslowikowska added the support:1 An issue reported by a commercially licensed client. label Dec 17, 2019
@Reinmar
Copy link
Member

Reinmar commented Feb 3, 2020

I wonder if it shouldn't be an option – that you can prevent CKEditor listening to events inside a certain UIElement but you don't have to.

@Reinmar
Copy link
Member

Reinmar commented Jun 24, 2020

This ticket dups #4600.

@Reinmar Reinmar closed this as completed Jun 24, 2020
@Reinmar Reinmar removed this from the backlog milestone Jun 24, 2020
@lslowikowska lslowikowska added support:3 An issue reported by a commercially licensed client. and removed support:1 An issue reported by a commercially licensed client. labels Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine support:3 An issue reported by a commercially licensed client. type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

No branches or pull requests

5 participants