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

HtmlEditor: Fix for context menu not closing when escape button pressed #28871

Open
wants to merge 2 commits into
base: 25_1
Choose a base branch
from

Conversation

nikkithelegendarypokemonster
Copy link
Contributor

No description provided.

@@ -71,6 +71,15 @@ if (Quill) {
eventsEngine.off(this.editorInstance._getContent(), CONTEXT_MENU_EVENT);
}

_escKeyHandler() {
this._contextMenu.hide();
Copy link
Contributor

Choose a reason for hiding this comment

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

[excess actions]
No need to call it here. Escape hides contextMenu by default, we only need to additonally focus the editor.

}

_addEscapeHandler(e) {
e.component.registerKeyHandler('escape', this._escKeyHandler.bind(this));
Copy link
Contributor

Choose a reason for hiding this comment

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

[refactoring]
I think it's overhead to create a separate method for _escKeyHandler. Let's just pass an arrow function here

this.editorInstance.focus();
}

_addEscapeHandler(e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's name it a bit wider while this method if passed to initialized

Suggested change
_addEscapeHandler(e) {
_onContextMenuInitialized(e) {

$tableElement.trigger('dxcontextmenu');
this.clock.tick(10);
const container = this.quillInstance.container;
$(container).trigger($.Event('keydown', { key: 'Escape', keyCode: 27, which: 27 }));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is supposed to be triggered on a contextMenu element

this.createWidget();

const $tableElement = this.$element.find('td').eq(0);
$tableElement.trigger('dxcontextmenu');
Copy link
Contributor

Choose a reason for hiding this comment

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

[copypaste]
Please use helper utils. U used this.createWidget, why don't u use this.getContextMenu?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants