fix(carousel): replace translate-based centering to fix nav button click misses#10296
Open
speixoto12 wants to merge 1 commit into
Open
fix(carousel): replace translate-based centering to fix nav button click misses#10296speixoto12 wants to merge 1 commit into
speixoto12 wants to merge 1 commit into
Conversation
Contributor
|
@speixoto12 is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
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 #10084
The carousel
CarouselPreviousandCarouselNextbuttons usetop-1/2 -translate-y-1/2to center themselves vertically in horizontal mode. However, shadcn's base Button styles includeactive:not-aria-[haspopup]:translate-y-px, which applies a 1px downward shift on click for tactile feedback.Both utilities target the same CSS
translateproperty. On click, the transform jumps from-50%to1px, displacing the button by roughly half the carousel's height instead of 1px. This moves the button out from under the pointer beforemouseupfires, causing clicks to silently fail — especially noticeable when clicking near the top edge of the button.Fix
Replace
top-1/2 -translate-y-1/2withinset-y-0 my-autoon the nav buttons. Centering via auto margins instead of a transform frees up thetranslateproperty entirely, allowing the active press effect to work as originally intended — a subtle 1px shift with no conflict.Why this approach
active:translate-y-pxnow works correctlyrather than being replaced or worked around
elements with
inset-y-0Related PRs
Changes
apps/v4/registry/bases/base/ui/carousel.tsxapps/v4/registry/bases/radix/ui/carousel.tsxpnpm registry:build