Skip to content

Commit 462e225

Browse files
fix(select-field): prevent ghost clicks on touch devices
1 parent 22f9823 commit 462e225

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/bento-design-system/src/SelectField/components.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,20 @@ export function MenuList<A extends { disabled?: boolean }>(props: MenuListProps<
228228
}
229229

230230
export function Option<B, A extends SelectOption<B>>(props: OptionProps<A>) {
231+
const { innerProps } = props;
232+
231233
return (
232-
<defaultComponents.Option {...props}>
234+
<defaultComponents.Option
235+
{...props}
236+
innerProps={{
237+
...innerProps,
238+
// On touch devices, prevent the browser from synthesizing a follow-up click
239+
// that could hit whatever is behind the menu after it closes.
240+
onTouchEnd: (e) => {
241+
e.preventDefault();
242+
},
243+
}}
244+
>
233245
<ListItem
234246
{...props.data}
235247
size={props.selectProps.menuSize ?? "medium"}

0 commit comments

Comments
 (0)