Skip to content

Commit

Permalink
fix: Prevent default keyboard actions when inline add focused
Browse files Browse the repository at this point in the history
This is to prevent navigating/deleteing staged tags in the react-select
menu when the inline add button is focused.
  • Loading branch information
yusuf-musleh committed Mar 12, 2024
1 parent 2b35fb8 commit 9c4c985
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/content-tags-drawer/ContentTagsCollapsible.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ const CustomMenu = (props) => {
);
};

const disableActionKeys = (e) => {
const arrowKeys = ['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft', 'Backspace'];
if (arrowKeys.includes(e.code)) {
e.preventDefault();
}
};

const CustomLoadingIndicator = () => {
const intl = useIntl();
return (
Expand Down Expand Up @@ -131,6 +138,7 @@ const CustomIndicatorsContainer = (props) => {
onMouseDown={(e) => { e.stopPropagation(); e.preventDefault(); }}
ref={selectInlineAddRef}
tabIndex="0"
onKeyDown={disableActionKeys} // To prevent navigating staged tags when button focused
>
{ intl.formatMessage(messages.collapsibleInlineAddStagedTagsButtonText) }
</Button>
Expand Down

0 comments on commit 9c4c985

Please sign in to comment.