-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Tests in classic editor #15901
Tests in classic editor #15901
Conversation
} ); | ||
} ); | ||
|
||
describe( 'Restoring focus on Esc key press', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a follow-up: We're going to need this kind of logic for the menu bar as well.
ckeditor5/packages/ckeditor5-ui/src/editorui/editorui.ts
Lines 437 to 464 in 76919d5
editor.keystrokes.set( 'Esc', ( data, cancel ) => { | |
const focusedToolbarDef = this._getCurrentFocusedToolbarDefinition(); | |
if ( !focusedToolbarDef ) { | |
return; | |
} | |
// Bring focus back to where it came from before focusing the toolbar: | |
// 1. If it came from outside the engine view (e.g. source editing), move it there. | |
if ( lastFocusedForeignElement ) { | |
lastFocusedForeignElement.focus(); | |
lastFocusedForeignElement = null; | |
} | |
// 2. There are two possibilities left: | |
// 2.1. It could be that the focus went from an editable element in the view (root or nested). | |
// 2.2. It could be the focus went straight to the toolbar before even focusing the editing area. | |
// In either case, just focus the view editing. The focus will land where it belongs. | |
else { | |
editor.editing.view.focus(); | |
} | |
// Clean up after the toolbar if there is anything to do there. | |
if ( focusedToolbarDef.options.afterBlur ) { | |
focusedToolbarDef.options.afterBlur(); | |
} | |
cancel(); | |
} ); |
I coded the prototype as fast as possible so I didn't consider cases where the focus must get back to some other place (e.g. source editing).
I suppose EditorUI#addMenuBar
corresponding to addToolbar
would be a good idea. Because currently, the keystroke handling code for the menu bar is in ClassicEditorUI
, and if sb wanted to build their editor, they wouldn't be able to add a menu bar without duplicating the code.
Suggested merge commit message (convention)
Tests (classic-editor): Add tests for menu bar. Related to #15894.
Additional information
For example – encountered issues, assumptions you had to make, other affected tickets, etc.