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 Combobox hidden input default value causing React warnings (name prop) #6336

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sookmax
Copy link
Contributor

@sookmax sookmax commented May 6, 2024

Closes #6327

It just occurred to me that it might also be nice to update the type for selectedKey from Key to Key | null.
Should I include that as well? Or maybe it's better to address it when converting packages/@react-stately/list to TS strict later (I don't see it on the typescript-strict-plugin list in tsconfig.json).

export interface SingleSelectListState<T> extends ListState<T> {
/** The key for the currently selected item. */
readonly selectedKey: Key,
/** Sets the selected key. */
setSelectedKey(key: Key | null): void,
/** The value of the currently selected item. */
readonly selectedItem: Node<T>
}

βœ… Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

πŸ“ Test Instructions:

Story

🧒 Your Project:

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

Probably easier to address the ts strict separately, I suspect it'll be non-trivial. But if it's easy, then feel free to add it.

Would you mind adding a name to a combobox test? It'll log the warning and we fail the tests if any logs are in our output.

@sookmax
Copy link
Contributor Author

sookmax commented May 8, 2024

Probably easier to address the ts strict separately, I suspect it'll be non-trivial. But if it's easy, then feel free to add it.

I agree. I'll take a look later if I have some down times πŸ˜„

Would you mind adding a name to a combobox test? It'll log the warning and we fail the tests if any logs are in our output.

This is cool! I verified the React warnings result in test failures when the name prop was added and the fix was removed. And yes I added name to TestComboBox in ComboBox.test.js.

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.

ComboBox with name property - warnings in console.
2 participants