Skip to content

Commit

Permalink
fix: enter key not closing the account modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer authored and AntonLantukh committed Feb 22, 2024
1 parent 1d2f25f commit 1791b4c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/ui-react/src/components/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ const IconButton: React.FC<Props> = ({ children, onClick, tabIndex = 0, classNam
onClick={onClick}
role="button"
tabIndex={tabIndex}
onKeyDown={(event: React.KeyboardEvent) => (event.key === 'Enter' || event.key === ' ') && tabIndex >= 0 && onClick && onClick()}
onKeyDown={(event: React.KeyboardEvent) => {
if ((event.key === 'Enter' || event.key === ' ') && tabIndex >= 0 && onClick) {
onClick();
event.preventDefault(); // prevent click being called when this component unmounts
}
}}
{...ariaProps}
>
{children}
Expand Down

0 comments on commit 1791b4c

Please sign in to comment.