fix(autocomplete): duplicate id in clear & selector button#5750
Conversation
🦋 Changeset detectedLatest commit: dc81692 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughIntroduces a changeset entry for @heroui/autocomplete and updates use-autocomplete to adjust clear button prop composition and focus/tab behavior by using only slotsProps.clearButtonProps and adding preventFocusOnPress and excludeFromTabOrder flags. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant CB as ClearButton
participant AC as useAutocomplete
participant IN as Input
Note over CB,AC: Clear button props now include preventFocusOnPress=true and excludeFromTabOrder=true
U->>CB: Click (press)
CB->>AC: onPressStart / onPress
AC->>AC: Clear value / update state
AC-->>IN: Notify input state updated
Note over U,CB: Focus is not moved to button (preventFocusOnPress)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (4 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.changeset/slow-maps-confess.md(1 hunks)packages/components/autocomplete/src/use-autocomplete.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: TypeScript
- GitHub Check: ESLint
- GitHub Check: Continuous Release
- GitHub Check: Tests
- GitHub Check: Build
🔇 Additional comments (2)
packages/components/autocomplete/src/use-autocomplete.ts (2)
437-445: Correctly retainsbuttonPropsfor the selector button.The selector button correctly continues to merge
buttonPropsfromuseComboBox, as this button is the actual trigger/combobox button that needs the ID, ARIA attributes, and event handlers provided by React Aria.The distinction is important:
- Selector button: The main trigger button that opens/closes the dropdown - needs
buttonProps- Clear button: A secondary action button - should NOT receive the same
buttonProps(would cause duplicate IDs)
449-451: RemovebuttonPropsfrom clear button props
MergingbuttonProps(which includes menu‐toggle ARIA attributes—aria-haspopup, aria-expanded, id—and event handlers for the combo‐box trigger) into the clear button was unnecessary. The clear button now correctly uses onlyslotsProps.clearButtonPropsand addspreventFocusOnPressandexcludeFromTabOrderto keep focus on the input and remove it from tab order. No essential ARIA attributes or event handlers have been omitted. (react-spectrum.adobe.com)
@heroui/accordion
@heroui/alert
@heroui/autocomplete
@heroui/avatar
@heroui/badge
@heroui/breadcrumbs
@heroui/button
@heroui/calendar
@heroui/card
@heroui/checkbox
@heroui/chip
@heroui/code
@heroui/date-input
@heroui/date-picker
@heroui/divider
@heroui/drawer
@heroui/dropdown
@heroui/form
@heroui/image
@heroui/input
@heroui/input-otp
@heroui/kbd
@heroui/link
@heroui/listbox
@heroui/menu
@heroui/modal
@heroui/navbar
@heroui/number-input
@heroui/pagination
@heroui/popover
@heroui/progress
@heroui/radio
@heroui/ripple
@heroui/scroll-shadow
@heroui/select
@heroui/skeleton
@heroui/slider
@heroui/snippet
@heroui/spacer
@heroui/spinner
@heroui/switch
@heroui/table
@heroui/tabs
@heroui/toast
@heroui/tooltip
@heroui/user
@heroui/react
@heroui/system
@heroui/system-rsc
@heroui/theme
@heroui/use-aria-accordion
@heroui/use-aria-accordion-item
@heroui/use-aria-button
@heroui/use-aria-link
@heroui/use-aria-modal-overlay
@heroui/use-aria-multiselect
@heroui/use-aria-overlay
@heroui/use-callback-ref
@heroui/use-clipboard
@heroui/use-data-scroll-overflow
@heroui/use-disclosure
@heroui/use-draggable
@heroui/use-form-reset
@heroui/use-image
@heroui/use-infinite-scroll
@heroui/use-intersection-observer
@heroui/use-is-mobile
@heroui/use-is-mounted
@heroui/use-measure
@heroui/use-pagination
@heroui/use-real-shape
@heroui/use-ref-state
@heroui/use-resize
@heroui/use-safe-layout-effect
@heroui/use-scroll-position
@heroui/use-ssr
@heroui/use-theme
@heroui/use-update-effect
@heroui/use-viewport-size
@heroui/aria-utils
@heroui/dom-animation
@heroui/framer-utils
@heroui/react-rsc-utils
@heroui/react-utils
@heroui/shared-icons
@heroui/shared-utils
@heroui/stories-utils
@heroui/test-utils
commit: |
Closes #5738
📝 Description
⛳️ Current behavior (updates)
🚀 New behavior
💣 Is this a breaking change (Yes/No):
📝 Additional Information
Summary by CodeRabbit