Skip to content

Commit

Permalink
feat: a11n added to options. TAB navigation through options
Browse files Browse the repository at this point in the history
  • Loading branch information
mnik01 committed Apr 10, 2023
1 parent 93ca9fc commit da9d85d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/components/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ const Item: React.FC<ItemProps> = ({ item, primaryColor }) => {
<DisabledItem>{item.label}</DisabledItem>
) : (
<li
tabIndex={0}
onKeyDown={(e: React.KeyboardEvent<HTMLLIElement>) => {
if (e.key === ' ' || e.key === 'Enter') {
handleValueChange(item)
}
}}
aria-selected={isSelected}
role={"option"}
onClick={() => handleValueChange(item)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ const Select: React.FC<SelectProps> = ({
>
<div className="relative w-full" ref={ref}>
<div
tabIndex={0}
aria-expanded={open}
onKeyDown={onPressEnterOrSpace}
onClick={toggle}
Expand Down Expand Up @@ -207,6 +206,8 @@ const Select: React.FC<SelectProps> = ({
</p>
{!isDisabled && (
<div
role="button"
tabIndex={0}
onClick={e => removeItem(e, item)}
className={
classNames?.tagItemIconContainer
Expand Down Expand Up @@ -264,7 +265,6 @@ const Select: React.FC<SelectProps> = ({

{open && !isDisabled && (
<div
tabIndex={-1}
className={
classNames?.menu
? classNames.menu
Expand Down

0 comments on commit da9d85d

Please sign in to comment.