Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
UXPLATFORM-191 Fixed dropdown open issue
Browse files Browse the repository at this point in the history
  • Loading branch information
adavijit committed Apr 18, 2024
1 parent 8564550 commit bf256b5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/terra-form-select/src/shared/_Tag.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,28 @@ const Tag = ({
const theme = React.useContext(ThemeContext);
const tagRef = useRef(null);

const handleEnterKeyPress = (event) => {
const handleKeyPress = (event) => {
if ((event.key === 'Enter' || event.key === 'Backspace') && !disabled) {
event.stopPropagation();
onDeselect(value);
const previousLi = tagRef.current.previousElementSibling;

const selectInput = tagRef.current.closest('ul').parentElement.parentElement.children[1].children[0];
if (previousLi) {
const deselectElement = previousLi.children[1];
if (deselectElement) {
deselectElement.focus();
}
} else {
const nextLi = tagRef.current.nextElementSibling;
const parentUl = tagRef.current.closest('ul');
if (nextLi) {
const deselectElement = nextLi.children[1];
if (deselectElement) {
deselectElement.focus();
} else {
parentUl.click();
selectInput.focus();
}
} else {
parentUl.click();
selectInput.focus();
}
}
}
Expand All @@ -72,7 +71,7 @@ const Tag = ({
</span>
<span
id={`terra-tag-deselect-${value}`}
onKeyDown={handleEnterKeyPress}
onKeyDown={handleKeyPress}
className={cx('deselect')}
onClick={() => { if (!disabled) onDeselect(value); }}
tabIndex={!disabled ? 0 : -1}
Expand Down

0 comments on commit bf256b5

Please sign in to comment.