react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

Fix Combobox hidden input default value causing React warnings (name prop)

Open sookmax opened this issue 1 year ago โ€ข 1 comments

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:

sookmax avatar May 06 '24 15:05 sookmax

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.

sookmax avatar May 08 '24 13:05 sookmax

may I help in any way to proceed with the merge of this pr?

lorenzo-dallamuta avatar Jun 18 '24 12:06 lorenzo-dallamuta

@lorenzo-dallamuta shouldn't need anything, looks like we just didn't finish the review.

snowystinger avatar Jun 19 '24 00:06 snowystinger