File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
js/__internal/ui/html_editor/modules
testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ if (Quill) {
7171 eventsEngine . off ( this . editorInstance . _getContent ( ) , CONTEXT_MENU_EVENT ) ;
7272 }
7373
74+ _onContextMenuInitialized ( e ) {
75+ e . component . registerKeyHandler ( 'escape' , ( ) => {
76+ this . editorInstance . focus ( ) ;
77+ } ) ;
78+ }
79+
7480 _createContextMenu ( items ) {
7581 const $container = $ ( '<div>' ) . appendTo ( this . editorInstance . $element ( ) ) ;
7682 const menuConfig = this . _getMenuConfig ( items ) ;
@@ -160,6 +166,9 @@ if (Quill) {
160166 target : this . _quillContainer ,
161167 showEvent : null ,
162168 hideOnParentScroll : false ,
169+ onInitialized : ( e ) => {
170+ this . _onContextMenuInitialized ( e ) ;
171+ } ,
163172 items : customItems ,
164173 } ;
165174 }
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ const CONTEXT_MENU_OVERLAY_SELECTOR = '.dx-context-menu.dx-overlay-content';
3333const ITEM_HAS_SUBMENU_CLASS = 'dx-menu-item-has-submenu' ;
3434const ITEM_HAS_TEXT_CLASS = 'dx-menu-item-has-text' ;
3535const SUBMENU_CLASS = 'dx-submenu' ;
36+ const HTML_EDITOR_CONTENT_CLASS = 'dx-htmleditor-content' ;
3637const SUBMENU_ITEMS_SELECTOR = `.${ SUBMENU_CLASS } .${ SUBMENU_CLASS } .${ ITEM_HAS_TEXT_CLASS } ` ;
3738
3839module ( 'Table context menu integration' , {
@@ -383,6 +384,21 @@ module('Table context menu integration', {
383384
384385 assert . strictEqual ( $table . length , 0 , 'Table is deleted' ) ;
385386 } ) ;
387+
388+ test ( 'Pressing escape button should return focus to html editor' , function ( assert ) {
389+ this . createWidget ( ) ;
390+
391+ const contextMenu = this . getContextMenu ( ) ;
392+ const $editorContent = $ ( `.${ HTML_EDITOR_CONTENT_CLASS } ` ) ;
393+
394+ contextMenu . trigger ( $ . Event ( 'keydown' , { key : 'Escape' , keyCode : 27 , which : 27 } ) ) ;
395+ this . clock . tick ( 10 ) ;
396+
397+ const shadowRoot = document . activeElement . shadowRoot ;
398+ const activeElement = shadowRoot ? shadowRoot . activeElement : document . activeElement ;
399+
400+ assert . strictEqual ( activeElement , $editorContent . get ( 0 ) , 'Editor should regain focus after Escape' ) ;
401+ } ) ;
386402 } ) ;
387403
388404 module ( 'Custom context menu' , { } , ( ) => {
You can’t perform that action at this time.
0 commit comments