-
-
Notifications
You must be signed in to change notification settings - Fork 2k
fix: isClearable handling #5913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
fix: isClearable handling #5913
Conversation
🦋 Changeset detectedLatest commit: c1a8504 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 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 |
|
@deepansh946 is attempting to deploy a commit to the HeroUI Inc Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis PR makes Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer (props)
participant Hook as useInput / useNumberInput
participant UI as Component UI
participant User as End user
Dev->>Hook: pass props (isClearable?, onClear?, readOnly?)
Note over Hook: compute isClearable = originalProps.isClearable ?? false
Hook-->>UI: render (show clear button only if isClearable && !readOnly)
User->>UI: press Clear button
UI->>Hook: call onClear (if provided)
User->>UI: press Escape
alt isClearable && !readOnly
UI->>Hook: handle Escape -> call onClear (if provided)
else
UI->>UI: ignore Escape for clearing
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
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. Comment |
|
@wingkwong I have fixed the isClearable implicit issue, please review it. |
@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 #5614
📝 Description
This PR fixes the implicit
isClearablebehavior inInputandNumberInputcomponents. Previously, providing anonClearcallback would automatically enable the clear button, even whenisClearablewas not explicitly set. This made the API unpredictable and violated separation of concerns.⛳️ Current behavior (updates)
Before:
isClearablewas implicitly enabled whenonClearprop was providedisClearablewas true ORonClearwas providedisClearableis not explicitly set, the clear button will be shown when this prop is provided."Example of problematic behavior:
🚀 New behavior
After:
isClearableis now controlled only by the explicit propisClearableis explicitlytrueonClearis simply a callback executed when the clear button is clicked (if visible)Example of new explicit behavior:
💣 Is this a breaking change (Yes/No):
Yes
Impact:
onClearwithoutisClearable) will no longer show the clear buttonisClearable={true}to show the clear buttonMigration path:
onClearis provided withoutisClearableisClearable={true}prop to enable the clear buttononClearwithoutisClearable(the callback will still work if triggered programmatically)Before:
After:
Summary by CodeRabbit
Refactor
Tests
Chores