Skip to content

Commit

Permalink
🐛Autocomplete: Added a workaround for touch crash (#3005)
Browse files Browse the repository at this point in the history
* 🐛Autocomplete: Added a workaround for touch crash

* update snapshot
  • Loading branch information
oddvernes authored Aug 14, 2023
1 parent bc2f4a8 commit dc8c22f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const StyledListItem = styled.li<StyledListItemType>(
background-color: ${backgroundColor};
user-select: none;
overflow: hidden;
touch-action: manipulation;
cursor: ${highlighted === 'true' ? 'pointer' : 'default'};
${typographyTemplate(theme.typography)}
${spacingsTemplate(theme.spacings)}
Expand Down Expand Up @@ -80,7 +81,12 @@ function AutocompleteOptionInner<T>(
isdisabled={isDisabled ? 'true' : 'false'}
aria-hidden={isDisabled}
active={!multiple && isSelected ? 'true' : 'false'}
onClick={(e) => !isDisabled && onClick(e)}
onClick={(e) => {
//timeout: workaround for "Maximum update depth exceeded" error that happens when touch input
setTimeout(() => {
!isDisabled && onClick(e)
}, 0)
}}
aria-selected={multiple ? isSelected : ariaSelected}
{...other}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ exports[`Autocomplete Matches snapshot 1`] = `
-ms-user-select: none;
user-select: none;
overflow: hidden;
touch-action: manipulation;
cursor: default;
margin: 0;
color: var(--eds_text__static_icons__default,rgba(61,61,61,1));
Expand Down

0 comments on commit dc8c22f

Please sign in to comment.