react-spectrum
react-spectrum copied to clipboard
Popover and ListBox inside ComboBox behave incorrectly
Provide a general summary of the issue here
Popover content inside ComboBox getting flash and then hidden whenever items props become an empty array, and then if the items is updated to whatever (an array with n items), the content still not rendering
๐ค Expected Behavior?
ComboBox isOpen state behaves correctly when items is updated to an empty array
๐ฏ Current Behavior
when an empty array is passed to ComboBox, Popover component become buggy
๐ Possible Solution
No response
๐ฆ Context
No response
๐ฅ๏ธ Steps to Reproduce
https://codesandbox.io/s/infallible-allen-67nywq?file=/src/ComboBox.tsx
try to input zz and you'll see the ListBox empty content flashes, the empty content rendered and then the popover isOpen changed into false immediately.
Then try to delete 1 z, the items is set to default again (with 5 items), the expected behaviour is the popover would shown again with 5 items, but current behaviour is the popover still not show until you input something to trigger a render
Version
latest
What browsers are you seeing the problem on?
Chrome, Microsoft Edge, Other
If other, please specify.
Arc
What operating system are you using?
MacOS
๐งข Your Company/Team
No response
๐ท Tracking Issue
No response
This is in a similar vein to https://github.com/adobe/react-spectrum/issues/2333 and https://github.com/adobe/react-spectrum/issues/3392, our RSP ComboBox supports empty collections via the allowEmptyCollection. RAC ComboBox doesn't do the same hence why you are seeing the popover close immediately. You can force this by providing allowEmptyCollection to the RAC ComboBox even though that isn't technically a supported prop like so: https://codesandbox.io/s/winter-frog-csp3vt but other issues arise when you hit the down arrow in this case which we'll want to address as well.
Hi @LFDanLu, thank you for the quick response, the property allowEmptyCollection in your comment is missing a s in allow => allowsEmptyCollection, it worked, I'll make a workaround for the down arrow issue for my case at the moment.
What's the issues with the down arrows with this prop @6thpath @LFDanLu, ran into this same issue when POCing the RAC library for our company ๐
I think @6thpath might be talking about an error in the keyboard delegate when using ArrowUp/ArrowDown with a empty collection in ComboBox that was fixed in https://github.com/adobe/react-spectrum/commit/cc4d1218cf7122941b53ab5f789b4dc59fe6f754.