Open h9ee opened 5 months ago
This seems relevant: https://github.com/shadcn-ui/ui/issues/486
One of the comments provides this as a fix and it worked for me:
<SelectContent ref={(ref) => { if (!ref) return; ref.ontouchstart = (e) => { e.preventDefault(); }; }} >
Describe the bug
When using the SortProduct component in a Next.js project with React, clicking on the sort dropdown inadvertently triggers a click on the product card located behind the dropdown. This unintended interaction likely occurs due to event propagation where the click event on the dropdown is not confined to the dropdown itself but bubbles up to other elements.
Clicking on the sort dropdown should only trigger the dropdown actions (i.e., displaying options and allowing the user to select one) without affecting other UI components behind or around the dropdown.
Clicking the sort dropdown triggers both the dropdown's functionality and the click event of a product card that lies in the background, possibly navigating away from the current view or executing other unintended actions associated with the product card.
Affected component/components
Select
How to reproduce
` const stopPropagation = (e: React.MouseEvent) => { e.stopPropagation(); };
`
i added onClick on type :
export interface SelectProps { children?: React.ReactNode; value?: string; defaultValue?: string; onValueChange?(value: string): void; open?: boolean; defaultOpen?: boolean; onOpenChange?(open: boolean): void; dir?: Direction; name?: string; autoComplete?: string; disabled?: boolean; required?: boolean; onClick?: (event: React.MouseEvent<HTMLDivElement>) => void; }
Codesandbox/StackBlitz link
No response
Logs
No response
System Info
Before submitting