everweij / react-laag

Hooks to build things like tooltips, dropdown menu's and popovers in React

Home Page:https://www.react-laag.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE] Ability to close child layers when parent scrolls

mtmacdonald opened this issue · comments

Is your feature request related to a problem? Please describe.

When I scroll the parent, react-laag tries to reposition open layers. Mostly this works quite nicely, but sometimes I get very strange positioning (e.g. off the page, so it becomes invisible). An extreme example is when I have nested menus with scrolling parents layers (needed sometimes for long lists). Here is an example (also see screenshots).

Screenshot 2021-03-09 at 14 24 46

Screenshot 2021-03-09 at 14 24 57

Describe the solution you'd like
I would like react-laag to propose a solution to the repositioning problem when a parent layer scrolls. If that's not possible I'd like some advice on what to do in this scenario.

Taking inspiration from native browser elements (e.g. the native select input), they seem to handle it by closing the child layer when the parent scrolls. Is that an approach react-laag can do for me automatically? If not, any implementation tips?

Describe alternatives you've considered

  • I've considering adding an onScroll event listener to the parent layer, and using that to trigger closing of child layers
  • I've considered preventing scroll on the parent when the layer is open (more like a 'modal' approach)

(Optional) Do you want to work on this feature?

Additional context