fix(Carousel): add onKeydown to Next/Previous for non-native element keyboard activation#639
Open
sridhar-3009 wants to merge 2 commits into
vuetifyjs:mastervuetifyjs/0:masterfrom
sridhar-3009:fix/carousel-keyboard-nav-next-prevsridhar-3009/0:fix/carousel-keyboard-nav-next-prevCopy head branch name to clipboard
Open
fix(Carousel): add onKeydown to Next/Previous for non-native element keyboard activation#639sridhar-3009 wants to merge 2 commits intovuetifyjs:mastervuetifyjs/0:masterfrom sridhar-3009:fix/carousel-keyboard-nav-next-prevsridhar-3009/0:fix/carousel-keyboard-nav-next-prevCopy head branch name to clipboard
sridhar-3009 wants to merge 2 commits into
vuetifyjs:mastervuetifyjs/0:masterfrom
sridhar-3009:fix/carousel-keyboard-nav-next-prevsridhar-3009/0:fix/carousel-keyboard-nav-next-prevCopy head branch name to clipboard
Conversation
…keyboard activation Carousel.Next and Carousel.Previous only exposed onClick in their slot-prop attrs. When rendered with as='div' (or any non-button element), browsers do not synthesize click events from Enter/Space keypresses, silently breaking keyboard navigation. Add onKeydown handlers to both components that call the existing onClick logic when Enter or Space is pressed, matching the pattern already used by CarouselIndicator. Also add tests that mount each button as as='div' and assert Enter advances/retreats the slide.
Contributor
|
✅ Changeset found — this change will be included in the next release. Thanks! |
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
Carousel.NextandCarousel.Previousonly exposedonClickin theirattrsslot props. When rendered withas='div'(or any non-button element), browsers do not synthesizeclickevents from Enter or Space keypresses, silently breaking keyboard navigation for users who rely on keyboards or ATonKeydownhandlers to both components that call the existingonClicklogic when Enter or Space is pressed — the same pattern already used byCarouselIndicatoronKeydowntype is added toCarouselNextSlotProps.attrsandCarouselPreviousSlotProps.attrsso TypeScript consumers know it's availableWhat changed
CarouselNext.vue: newonKeydownfunction callingonClick()on Enter/Space; exposed inslotProps.attrs; type added toCarouselNextSlotPropsCarouselPrevious.vue: same changes symmetricallyindex.test.ts: two new tests — one for each component — mounting withas='div'and asserting Enter/Space trigger slide navigationTest plan
Carousel.Nextrendered asdiv: Enter key advances to next slideCarousel.Previousrendered asdiv: Enter key moves to previous slidedefaultPrevented)