fix(drawer): prevent vaul pointer capture on native form elements (date picker, select)#9695
Open
eduardbar wants to merge 1 commit intoshadcn-ui:mainfrom
Open
Conversation
vaul calls setPointerCapture in its onPress() handler on DrawerContent, which intercepts pointer events before native browser UI (e.g. the date picker calendar popup) can process them. Wrapping children in a display:contents div that stops synthetic event propagation for native interactive elements prevents vaul's onPointerDown from firing, restoring native input[type=date], select, and contenteditable behavior. Fixes shadcn-ui#9578
Contributor
|
Someone is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes native browser controls (date pickers, selects, contenteditable elements) not working inside Drawers on Chrome desktop.
Fixes #9578
Bug
When a user clicks on a native
<input type="date">(or<select>, or[contenteditable]) inside a Drawer, the native browser UI (e.g. the calendar popup for date inputs) never opens.Root Cause
vaul's
DrawerContentattaches anonPointerDownhandler that callselement.setPointerCapture(event.pointerId)inside itsonPress()logic. This captures all subsequent pointer events on the element, which means the browser never receives the pointer events it needs to open native UI (like the date picker calendar). The browser requires uninterrupted pointer ownership to show these native popups — oncesetPointerCaptureis called, the native widget loses its chance to respond.Fix
Wrap
{children}in adisplay:contentsdiv with anonPointerDownhandler that callse.stopPropagation()when the target is a native interactive element (input,textarea,select, or[contenteditable]). This stops the synthetic React event from bubbling up to vaul's handler, preventingsetPointerCapturefrom firing for these elements.className="contents"uses CSSdisplay: contents, which makes the div invisible to the layout engine — zero layout impact, no box is generated.Files Changed
apps/v4/registry/new-york-v4/ui/drawer.tsxapps/v4/registry/bases/base/ui/drawer.tsxapps/v4/registry/bases/radix/ui/drawer.tsxdeprecated/www/registry/new-york/ui/drawer.tsxdeprecated/www/registry/default/ui/drawer.tsx