Skip to content

Commit

Permalink
Writing flow: Fix focus trap on certain input types
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Jun 6, 2022
1 parent bd87746 commit d27e478
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/block-editor/src/components/writing-flow/use-arrow-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,25 @@ export function isNavigationCandidate( element, keyCode, hasModifier ) {
return true;
}

// Native inputs should not navigate horizontally.
const { tagName } = element;
return tagName !== 'INPUT' && tagName !== 'TEXTAREA';

// Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.
if ( tagName === 'INPUT' ) {
const simpleInputTypes = [
'button',
'checkbox',
'color',
'file',
'image',
'radio',
'reset',
'submit',
];
return simpleInputTypes.includes( element.getAttribute( 'type' ) );
}

// Native textareas should not navigate horizontally.
return tagName !== 'TEXTAREA';
}

/**
Expand Down

0 comments on commit d27e478

Please sign in to comment.