dialog icon indicating copy to clipboard operation
dialog copied to clipboard

Prevent page jump when opening the dialog

Open NetanelBasal opened this issue 4 years ago • 6 comments

When we open the dialog, we remove the page scrollbar, which causes a layout jump.

@tonivj5 wdyt?

NetanelBasal avatar Feb 17 '21 13:02 NetanelBasal

Could you add a repro or an example? I don't see any layout jump in https://ngneat.github.io/dialog/

tonivj5 avatar Feb 18 '21 16:02 tonivj5

It's happennig in the playground. Toggle the dialog and focus on the end of this block:

Screen Shot 2021-02-19 at 10 59 19

NetanelBasal avatar Feb 19 '21 09:02 NetanelBasal

Use this button to toggle it:

Screen Shot 2021-02-19 at 11 02 03

NetanelBasal avatar Feb 19 '21 09:02 NetanelBasal

I've been looking for a solution, and it seems to be a bit harder to fix. I've checked how ng-bootstrap does it, it compensates the scrollbar gap adding a synthetic right padding, simulating scrollbar is there. We could take the same approach.

Others thoughts:

  • Do nothing as Angular material does (if body has scrollbar, doesn't hide it)
  • Or add a class to body/html indicating dialog is opened, and let the user to add his logic if he want to hide scroll and handle reflow.

wdty @NetanelBasal?

tonivj5 avatar Mar 01 '21 22:03 tonivj5

I think we should follow the Angular material approach. But pay attention that it needs to behave the same:

  • Don't hide the scrollbar
  • Prevent scrolling

NetanelBasal avatar Mar 02 '21 06:03 NetanelBasal

@tonivj5 any progress here?

NetanelBasal avatar May 14 '21 04:05 NetanelBasal