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

ComboBox list items not scrolling

Open upender7270 opened this issue 1 year ago โ€ข 7 comments

Provide a general summary of the issue here

I am integrating comboBox with my React app, React - v18 Node - v20.7.0 OS - Ubuntu 22.04.4 LTS

"@adobe/react-spectrum": "^3.34.1",
"@react-spectrum/combobox": "^3.12.3",
"@react-spectrum/provider": "^3.9.5",

https://github.com/adobe/react-spectrum/assets/43287621/bb3c03d0-d057-44b3-b541-b13c841104ef

๐Ÿค” Expected Behavior?

Should be able to scroll the items in the list box

๐Ÿ˜ฏ Current Behavior

Unable to scroll items in list box

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

  1. Clone the repo - https://github.com/upender7270/react-combobox
  2. yarn
  3. yarn storybook
  4. Open dynamic or static story of the combobox

Version

3.34.1

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Ubuntu

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

upender7270 avatar Apr 20 '24 09:04 upender7270

Yah yah I've also faced this issue many times. Someone please look into this.

RajaTheKing826 avatar Apr 20 '24 09:04 RajaTheKing826

@snowystinger just tested with the nightly and I still saw this issue, so seems unrelated.

reidbarber avatar Apr 22 '24 14:04 reidbarber

I was also looking into this issue at the moment, and realized PopoverWrapper was being rendered too many times (this can be verified with React Developer Tools). And this infinite rendering of <PopoverWrapper> seems to be the reason why we're unable to scroll.

It looks like the root cause of this chain rendering is the invocation of updatePosition() inside the onResize() callback here: https://github.com/adobe/react-spectrum/blob/72775d272be04cfa32d26ec821bc68513d92a72b/packages/%40react-aria/overlays/src/useOverlayPosition.ts#L195-L204

If the above updatePosition() is commented out, you'll see the working scroll:

https://github.com/adobe/react-spectrum/assets/71210554/46a0c1ea-64bc-4682-9f0b-9132e0bf6692

Update

Might be related to https://github.com/adobe/react-spectrum/issues/5653#issuecomment-2014972059 in terms of the change in behavior of resize event of VisualViewport.

sookmax avatar Apr 22 '24 15:04 sookmax

I'm experiencing the same issue. When the list is long enough and a scrollbar is rendered, the resize event from VisualViewport is triggered very often causing updatePosition to be called very often as well. This in turn causes the list to be unscrollable. It does not seem to be related to scrolling itself, since the resize event is triggering right after opening the ComboBox (see my second recording).

So far, I've only seen this happen when shouldFlip is set to false and isNonModal is set to true in ComboBox (as @sookmax already brought up in another issue). Setting shouldFlip to true (default behavior) or isNonModal to false doesn't seem to result in the repeated resize events.

Setting a fixed max-height on ListBox seems to fix the repeated resize events as well, but that causes the list to overflow the popover and trying to circumvent this through overflow-y either causes double scrollbars or parts of ListBox being hidden.

This recording shows scroll state resetting:

https://github.com/adobe/react-spectrum/assets/101109442/3c36bcb0-4f86-44a5-992c-e6feff4d2762

And this recording shows a console.log whenever resize is triggered on visualViewport.

https://github.com/adobe/react-spectrum/assets/101109442/caac9ca8-b2e5-40c7-af44-b18f293ee8e2

youssrikrap-cpi avatar Apr 25 '24 09:04 youssrikrap-cpi

If it helps, I've noticed that rolling back one version to 3.33.1 fixes it, so it must have been introduced by a commit between that and 3.34.0.

dsmmcken avatar Apr 30 '24 22:04 dsmmcken

Another thing I noticed was it only happens if the parent doesn't contain enough space to fit the list, so for example:

Works:

<View height="4000px"> // height bigger than list
  <ComboBox
    label="test"
    items={Array.from({ length: 200 }, (_, index) => ({
      name: `Item ${index}`,
      key: index,
    }))}
  >
    {(item) => <Item>{item.name}</Item>}
  </ComboBox>
</View>

Doesn't work:

<View height="1000px"> // height smaller than list
  <ComboBox
    label="test"
    items={Array.from({ length: 200 }, (_, index) => ({
      name: `Item ${index}`,
      key: index,
    }))}
  >
    {(item) => <Item>{item.name}</Item>}
  </ComboBox>
</View>

dsmmcken avatar May 01 '24 15:05 dsmmcken

Looks like we broke this in https://github.com/adobe/react-spectrum/pull/5808

snowystinger avatar May 01 '24 18:05 snowystinger

This is now fixed in the latest patch release.

devongovett avatar May 21 '24 00:05 devongovett