react-spectrum
react-spectrum copied to clipboard
Fix Combobox hidden input default value causing React warnings (name prop)
Closes https://github.com/adobe/react-spectrum/issues/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).
https://github.com/adobe/react-spectrum/blob/cf0846eb49fcdde669e9dc4c0c2d2109b50e46dd/packages/%40react-stately/list/src/useSingleSelectListState.ts#L25-L34
โ Pull Request Checklist:
- [x] Included link to corresponding React Spectrum GitHub Issue.
- [x] Added/updated unit tests and storybook for this change (for new code or code which already has tests).
- [x] 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
- Visit http://localhost:9003/?path=/story/react-aria-components--combo-box-example&providerSwitcher-express=false&strict=true
- Open up the inspector and check there's no React warnings about 'uncontrolled components'
๐งข Your Project:
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.
may I help in any way to proceed with the merge of this pr?
@lorenzo-dallamuta shouldn't need anything, looks like we just didn't finish the review.