nextui icon indicating copy to clipboard operation
nextui copied to clipboard

Fix/listbox remove deprecated isdisabled

Open dharmveer97 opened this issue 2 months ago โ€ข 3 comments

Closes #5863

๐Ÿ“ Description

This PR removes the deprecated isDisabled and isSelected props from ListboxItem and AutocompleteItem components. These props were deprecated in react-aria's AriaOptionProps interface and should no longer be exposed to users.

โ›ณ๏ธ Current behavior (updates)

Currently, ListboxItem and AutocompleteItem inherit all props from react-aria's AriaOptionProps, including the deprecated isDisabled and isSelected props. This allows users to write code like:

<Autocomplete>
  <AutocompleteItem key="penguin" isDisabled>
    Penguin
  </AutocompleteItem>
</Autocomplete>

However, this pattern is deprecated in react-aria and triggers deprecation warnings in TypeScript.

๐Ÿš€ New behavior

After this PR, the deprecated props are excluded from the type definition. Users must use the disabledKeys prop on the parent component instead:

<Autocomplete disabledKeys={["penguin"]}>
  <AutocompleteItem key="penguin">
    Penguin
  </AutocompleteItem>
</Autocomplete>

This approach:

  • โœ… Eliminates deprecation warnings
  • โœ… Follows react-aria's recommended patterns
  • โœ… Centralizes disabled state management
  • โœ… Provides better consistency with accessibility patterns

Changes made:

  • Excluded isDisabled and isSelected from AriaOptionProps inheritance in ListboxItemBaseProps
  • Updated test file to use the correct disabledKeys pattern
  • Added changeset documenting the change

๐Ÿ’ฃ Is this a breaking change (Yes/No):

Yes - Minor breaking change

Impact

Users who are using isDisabled or isSelected props directly on ListboxItem or AutocompleteItem will get TypeScript errors after this update.

Migration Path

Replace individual item isDisabled props with the disabledKeys prop on the parent component:

Before:

<Autocomplete>
  <AutocompleteItem key="cat" isDisabled>Cat</AutocompleteItem>
  <AutocompleteItem key="dog">Dog</AutocompleteItem>
</Autocomplete>

After:

<Autocomplete disabledKeys={["cat"]}>
  <AutocompleteItem key="cat">Cat</AutocompleteItem>
  <AutocompleteItem key="dog">Dog</AutocompleteItem>
</Autocomplete>

This pattern works for all components using ListboxItem: Autocomplete, Select, Listbox, Dropdown, etc.

๐Ÿ“ Additional Information

  • This aligns HeroUI with react-aria's current best practices
  • The disabledKeys pattern has been the recommended approach and is already widely used in the codebase
  • All existing examples and documentation already use disabledKeys, so most users should not be affected
  • Related react-aria issue: The isDisabled prop in AriaOptionProps was marked as deprecated to encourage centralized disabled state management

Summary by CodeRabbit

Release Notes

  • Breaking Changes

    • Removed deprecated isDisabled and isSelected props from listbox and autocomplete item components. Manage disabled state via the parent component's disabledKeys prop instead.
  • Documentation

    • Updated usage guidance and examples to reflect the new disabled state management pattern.

dharmveer97 avatar Nov 01 '25 15:11 dharmveer97

๐Ÿฆ‹ Changeset detected

Latest commit: 0dd973a60264f286f64aab8aabf54f85a74b6280

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@heroui/listbox Patch
@heroui/autocomplete Patch
@heroui/select Patch
@heroui/react Patch

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

changeset-bot[bot] avatar Nov 01 '25 15:11 changeset-bot[bot]

@dharmveer97 is attempting to deploy a commit to the HeroUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Nov 01 '25 15:11 vercel[bot]

Walkthrough

This pull request removes the deprecated isDisabled and isSelected props from ListboxItemBase and AutocompleteItem components, redirecting users to manage disabled state via the parent component's disabledKeys prop. Additionally, the docs layout is updated to replace RandomBanner with ProBanner.

Changes

Cohort / File(s) Summary
Deprecated Props Removal
packages/components/listbox/src/base/listbox-item-base.tsx
Updated ListboxItemBaseProps type to omit isDisabled and isSelected from AriaOptionProps, in addition to existing key omission
Test Updates
packages/components/autocomplete/__tests__/autocomplete.test.tsx
Removed isDisabled prop from AutocompleteItem in test case; item now rendered as enabled
Changeset Documentation
.changeset/remove-deprecated-isdisabled-prop.md
Documented removal of deprecated isDisabled and isSelected props with migration guidance to use parent disabledKeys; bumped @heroui/listbox and @heroui/autocomplete to patch versions
Docs Layout
apps/docs/app/layout.tsx
Replaced RandomBanner import and usage with ProBanner in RootLayout component

Estimated code review effort

๐ŸŽฏ 2 (Simple) | โฑ๏ธ ~12 minutes

  • Type changes in ListboxItemBaseProps are straightforward omissions from the AriaOptionProps interface
  • Test update is a single prop removal demonstrating the migration path
  • Changes are localized and non-breaking from an external API perspective (props are being removed per deprecation notice)

Possibly related PRs

  • #5827: Modifies isDisabled handling in autocomplete/listbox codebase alongside this PR's deprecation removal
  • #5835: Directly related โ€” also updates apps/docs/app/layout.tsx to replace RandomBanner with ProBanner

Suggested reviewers

  • jrgarciadev
  • wingkwong

Pre-merge checks and finishing touches

โŒ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check โš ๏ธ Warning The PR contains an out-of-scope change in apps/docs/app/layout.tsx that replaces RandomBanner with ProBanner. This documentation layout modification is unrelated to the stated objective of removing deprecated isDisabled and isSelected props from ListboxItem and AutocompleteItem components, and appears to be an accidental inclusion that should be removed or addressed in a separate PR to maintain PR focus and reviewability. Remove the apps/docs/app/layout.tsx change (RandomBanner to ProBanner replacement) from this PR as it is unrelated to the deprecated props removal objective. If this change is necessary, please address it in a separate pull request to keep this PR focused on its stated goal.
Docstring Coverage โš ๏ธ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
โœ… Passed checks (3 passed)
Check name Status Explanation
Title Check โœ… Passed The title "Fix/listbox remove deprecated isdisabled" captures the core objective of removing deprecated props from listbox-related components. However, the title is somewhat incomplete as it omits reference to the isSelected prop that is also being removed and does not clearly indicate that the changes affect both Listbox and Autocomplete components. While the title could be more comprehensive, it remains clear and specific enough to convey the primary change without being vague or generic.
Linked Issues Check โœ… Passed The PR successfully addresses the primary objective of issue #5863 by removing the deprecated isDisabled and isSelected props that were inherited from react-aria's AriaOptionProps. The implementation prevents users from accessing deprecated properties and provides a valid migration path using the parent component's disabledKeys prop, which aligns with react-aria's recommended patterns. While the issue suggested isReadonly as an alternative, the PR's approach using disabledKeys is the established best practice in the codebase and effectively resolves the deprecation issue.
Description Check โœ… Passed The PR description comprehensively addresses all required template sections: it includes the issue reference (Closes #5863), provides a clear description of the problem, explains both current and new behavior with code examples, explicitly marks this as a breaking change with detailed impact and migration guidance, and offers additional context about alignment with react-aria best practices. The description is well-organized, thorough, and provides sufficient information for reviewers and future maintainers.
โœจ Finishing touches
  • [ ] ๐Ÿ“ Generate docstrings
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

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.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 01 '25 15:11 coderabbitai[bot]