Skip to content

Commit

Permalink
[MultiSelect][base] Require a single tap to select an item on mobile …
Browse files Browse the repository at this point in the history
…Chrome (mui#33932)
  • Loading branch information
michaldudak authored and Daniel Rabe committed Nov 29, 2022
1 parent 3900913 commit b24f192
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/mui-base/src/ListboxUnstyled/useListbox.ts
Expand Up @@ -138,9 +138,9 @@ export default function useListbox<TOption>(props: UseListboxParameters<TOption>
});
};

const createHandleOptionMouseOver =
const createHandleOptionPointerOver =
(option: TOption, other: Record<string, React.EventHandler<any>>) =>
(event: React.MouseEvent) => {
(event: React.PointerEvent) => {
other.onMouseOver?.(event);
if (event.defaultPrevented) {
return;
Expand Down Expand Up @@ -298,11 +298,11 @@ export default function useListbox<TOption>(props: UseListboxParameters<TOption>
...otherHandlers,
'aria-disabled': optionState.disabled || undefined,
'aria-selected': optionState.selected,
tabIndex: getOptionTabIndex(optionState),
id: optionIdGenerator(option, index),
onClick: createHandleOptionClick(option, otherHandlers),
onMouseOver: createHandleOptionMouseOver(option, otherHandlers),
onPointerOver: createHandleOptionPointerOver(option, otherHandlers),
role: 'option',
tabIndex: getOptionTabIndex(optionState),
};
};

Expand Down
2 changes: 2 additions & 0 deletions packages/mui-base/src/ListboxUnstyled/useListbox.types.ts
Expand Up @@ -241,7 +241,9 @@ interface UseListboxOptionSlotOwnProps {
'aria-selected': React.AriaAttributes['aria-selected'];
id?: string;
onClick: React.MouseEventHandler;
onPointerOver: React.PointerEventHandler;
role: React.AriaRole;
tabIndex?: number;
}

export type UseListboxOptionSlotProps<TOther = {}> = Omit<
Expand Down
Expand Up @@ -14,6 +14,7 @@ const dummyGetOptionProps = () => ({
'aria-selected': false,
label: '',
onClick: () => {},
onPointerOver: () => {},
role: 'option',
value: '',
});
Expand Down

0 comments on commit b24f192

Please sign in to comment.