iTwin / iTwinUI-react

A react component library for iTwinUI.
https://github.com/iTwin/iTwinUI
Other
83 stars 23 forks source link

Select dropdown width is not automatically adjusted based on screen width #412

Closed irenajur closed 2 years ago

irenajur commented 2 years ago

Describe the bug (actual behavior)

Noticed this bug while inspecting the https://itwin.github.io/iTwinUI-react/?path=/story/input-select--many-items select styles. If you open the dropdown and then change the screen width - dropdown menu width will stay the same and might overflow out of the available screen width.

Expected behavior

Dropdown should not overflow the available screen width.

Reproduction

Link to a minimal repro: https://codesandbox.io/s/itwinui-react-select-issue-5yj3r

Steps to reproduce
  1. Open select dropdown
  2. Resize the screen width to smaller
mayank99 commented 2 years ago

Hi @irenajur 👋 Thanks for the issue.

I am not sure I would really consider this a bug worth fixing, as it would require adding resize observers which add extra complexity and could degrade performance (there was an effort in the past but it was abandoned for similar reasons).

It is not often that you open the dropdown and then resize the viewport. If you resize first and then open the dropdown, it behaves correctly.

@veekeys What do you think?

bentleyvk commented 2 years ago

I checked other libs when I implemented Select and no one was resizing dropdown menu when window was resized so I decided it is not worth the effort and as Mayank mentioned resize is handled correctly when dropdown menu is closed.

veekeys commented 2 years ago

Wouldnt be enough to use already existing resize observer for this? If it is really too much work, I guess I agree it is not worth the effort. I forgot we recalculate minWidth on opening, so thought having hardcoded value is not really good... I will remove this from our backlog for now, but maybe lets keep it in here for others to see we are aware...

veekeys commented 2 years ago

I am closing this.