Skip to content

Commit

Permalink
main.DomEvents: prevent Tab key default events for input fields used …
Browse files Browse the repository at this point in the history
…as table editors #6161
  • Loading branch information
tobiu committed Dec 18, 2024
1 parent acc9ee1 commit 1205e0f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/DomEvents.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -541,19 +541,28 @@ class DomEvents extends Base {
* @param {KeyboardEvent} event
*/
onKeyDown(event) {
let {target} = event,
let me = this,
{target} = event,
{tagName} = target,
isInput = tagName === 'INPUT' || tagName === 'TEXTAREA';

if (isInput && disabledInputKeys[target.id]?.includes(event.key)) {
event.preventDefault()
} else {
this.sendMessageToApp(this.getKeyboardEventData(event));
me.sendMessageToApp(me.getKeyboardEventData(event));

if (
isInput &&
event.key === 'Tab' &&
me.testPathInclusion(event, ['neo-table-editor'], true)
) {
event.preventDefault()
}

if (
!isInput &&
['ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp'].includes(event.key) &&
this.testPathInclusion(event, ['neo-selection'], true)
me.testPathInclusion(event, ['neo-selection'], true)
) {
event.preventDefault()
}
Expand Down

0 comments on commit 1205e0f

Please sign in to comment.