Skip to content
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

fix(select): SelectItem does not accept value props #4653

Open
wants to merge 2 commits into
base: canary
Choose a base branch
from

Conversation

ryo-manba
Copy link
Member

@ryo-manba ryo-manba commented Jan 26, 2025

Closes #2283

📝 Description

This PR includes the following changes:

  • Added documentation about handling the value attribute.
  • Updated SelectItem to not accept a value prop.

⛳️ Current behavior (updates)

SelectItem accepts a value prop (but it is not reflected).

🚀 New behavior

SelectItem no longer accepts a value prop.

💣 Is this a breaking change (Yes/No):

Yes

📝 Additional Information

For more details on why the value attribute cannot be used, please see the issue comment:
#2283 (comment)

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Removed value attribute from SelectItem components across multiple documentation and test files
    • Updated ListboxItemBase component to omit value property
  • Documentation

    • Added new section explaining how to handle form submissions with SelectItem
  • Dependencies

    • Minor version updates for @heroui/listbox and @heroui/select

These changes improve the consistency of SelectItem component usage and provide clearer guidance for developers.

Copy link

vercel bot commented Jan 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
heroui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 26, 2025 8:51am
heroui-sb ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 26, 2025 8:51am

Copy link
Contributor

coderabbitai bot commented Jan 26, 2025

Walkthrough

This pull request introduces changes to the SelectItem component across multiple files, removing the value prop and updating documentation. The modifications affect how values are handled in select components, with a focus on using the key property for form submissions. Minor version updates for @heroui/listbox and @heroui/select dependencies are also included, addressing an issue related to value properties in the SelectItem component.

Changes

File Path Change Summary
.changeset/light-hairs-draw.md Minor version updates for @heroui/listbox and @heroui/select dependencies
apps/docs/content/docs/components/select.mdx Added new section explaining value attribute usage and recommending key-based form submissions
apps/docs/content/components/form/demo.raw.jsx
apps/docs/content/components/select/*.raw.jsx
Removed value prop from SelectItem components, now using only key and children
packages/components/listbox/src/base/listbox-item-base.tsx Modified type signature to omit value property from ListboxItemBase component props
packages/components/select/__tests__/select.test.tsx Removed value props from SelectItem in test cases

Sequence Diagram

sequenceDiagram
    participant User
    participant SelectComponent
    participant SelectItem
    
    User->>SelectComponent: Interact with Select
    SelectComponent->>SelectItem: Render items
    SelectItem-->>SelectComponent: Display with key-based value
    User->>SelectComponent: Select an item
    SelectComponent->>SelectComponent: Use key for form submission
Loading

The sequence diagram illustrates the updated flow where SelectItem components are rendered and selected using their key property, simplifying the value handling process.

Assessment against linked issues

Objective Addressed Explanation
Ensure SelectItem uses key for values instead of value prop (#2283)
Allow form submissions to reflect selected values accurately (#2283)

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24d3467 and a6680b9.

📒 Files selected for processing (3)
  • apps/docs/content/components/select/virtualization-custom-item-height.raw.jsx (1 hunks)
  • apps/docs/content/components/select/virtualization-max-listbox-height.raw.jsx (1 hunks)
  • apps/docs/content/components/select/virtualization.raw.jsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/docs/content/components/select/virtualization-custom-item-height.raw.jsx
  • apps/docs/content/components/select/virtualization.raw.jsx
  • apps/docs/content/components/select/virtualization-max-listbox-height.raw.jsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: TypeScript
  • GitHub Check: Build

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (7)
apps/docs/content/components/select/virtualization.raw.jsx (1)

Line range hint 23-27: Consider removing unused value property from dataset.

The value property is generated in the dataset but no longer used after removing the value prop from SelectItem. If this property is not needed elsewhere, consider simplifying the dataset structure.

.changeset/light-hairs-draw.md (1)

6-6: Fix typo in PR description.

"dose" should be "does"

-Fix SelectItem dose not accept value props (#2283)
+Fix SelectItem does not accept value props (#2283)
🧰 Tools
🪛 LanguageTool

[misspelling] ~6-~6: Did you mean the auxiliary verb “does”?
Context: ...roui/select": minor --- Fix SelectItem dose not accept value props (#2283)

(DOSE_DOES)

packages/components/select/__tests__/select.test.tsx (4)

485-487: Add test cases for form submission with key prop

Since the value prop has been removed in favor of using key for form submissions, consider adding test cases that explicitly verify form submission behavior with the key prop.

Also applies to: 490-492


622-624: Add test case for key-based selection

Consider adding a test case that verifies the correct handling of the key prop in form submissions after removing the value prop.


663-663: Add virtualization tests for key-based selection

The virtualization tests should include verification of key-based selection and form submission behavior.

Also applies to: 699-699


729-731: Add accessibility tests for form labels

Consider adding tests to verify that form labels are correctly associated with the select component when using key-based selection.

Also applies to: 752-754

apps/docs/content/docs/components/select.mdx (1)

297-303: Enhance documentation with migration examples

While the explanation about using key instead of value is clear, consider adding:

  1. Code examples showing before/after migration
  2. Example of implementing a lookup map for custom form values
  3. Best practices for key selection in forms
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cddba82 and 24d3467.

📒 Files selected for processing (9)
  • .changeset/light-hairs-draw.md (1 hunks)
  • apps/docs/content/components/form/demo.raw.jsx (1 hunks)
  • apps/docs/content/components/select/virtualization-custom-item-height.raw.jsx (1 hunks)
  • apps/docs/content/components/select/virtualization-max-listbox-height.raw.jsx (1 hunks)
  • apps/docs/content/components/select/virtualization-ten-thousand.raw.jsx (1 hunks)
  • apps/docs/content/components/select/virtualization.raw.jsx (1 hunks)
  • apps/docs/content/docs/components/select.mdx (1 hunks)
  • packages/components/listbox/src/base/listbox-item-base.tsx (1 hunks)
  • packages/components/select/__tests__/select.test.tsx (10 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/content/components/form/demo.raw.jsx
🧰 Additional context used
🪛 LanguageTool
.changeset/light-hairs-draw.md

[misspelling] ~6-~6: Did you mean the auxiliary verb “does”?
Context: ...roui/select": minor --- Fix SelectItem dose not accept value props (#2283)

(DOSE_DOES)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: TypeScript
  • GitHub Check: Build
🔇 Additional comments (1)
apps/docs/content/components/select/virtualization.raw.jsx (1)

Line range hint 39-48: Verify form submission behavior after removing value prop.

Please ensure that form submissions still work correctly after removing the value prop. The PR description mentions this was a fix for SelectItem not accepting value props, but we should verify that the selected values are still properly handled.

Copy link

changeset-bot bot commented Jan 26, 2025

🦋 Changeset detected

Latest commit: a6680b9

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 Minor
@heroui/select Minor
@heroui/autocomplete 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - Select gets values from key prop, not value, into native select element
1 participant