Avoid scrolling to cursor when Control/Alt/Shift/Escape is hit

This behavior now matches other editors
This commit is contained in:
Mitch Capper 2022-03-16 15:46:12 -07:00
parent 03afc1ec29
commit fc26306b7e
2 changed files with 10 additions and 1 deletions

View File

@ -54,7 +54,12 @@ export const EVENT_KEYS = Object.freeze(generateKeyHash([
'ArrowLeft', 'ArrowLeft',
'ArrowRight', 'ArrowRight',
'Tab', 'Tab',
'Escape' 'Escape',
'Control',
'Alt',
'Shift',
'PageUp',
'PageDown'
])) ]))
export const LOWERCASE_TAGS = Object.freeze(generateKeyHash([ export const LOWERCASE_TAGS = Object.freeze(generateKeyHash([

View File

@ -68,6 +68,10 @@ class Keyboard {
) { ) {
return return
} }
if (event.key === EVENT_KEYS.Control || event.key === EVENT_KEYS.Alt || event.key === EVENT_KEYS.Escape || event.key === EVENT_KEYS.Shift || event.key === EVENT_KEYS.PageUp || event.key === EVENT_KEYS.PageDown) { // we don't want to focus on the cursor if the user just hits one of these keys. Other editors do not.
return
}
// Cursor outside editor area or over not editable elements. // Cursor outside editor area or over not editable elements.
if (event.target.closest('[contenteditable=false]')) { if (event.target.closest('[contenteditable=false]')) {
return return