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

Popover and ListBox inside ComboBox behave incorrectly

Open 6thpath opened this issue 2 years ago โ€ข 4 comments

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

6thpath avatar Sep 26 '23 10:09 6thpath

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.

LFDanLu avatar Sep 26 '23 18:09 LFDanLu

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.

6thpath avatar Sep 27 '23 03:09 6thpath

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 ๐Ÿ˜…

p1pah avatar Jan 25 '24 23:01 p1pah

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.

LFDanLu avatar Jan 29 '24 19:01 LFDanLu