TheOdinProject / theodinproject

Main Website for The Odin Project
http://www.theodinproject.com
MIT License
3.59k stars 2.06k forks source link

Bug: Layout shift when closing modals on small screens #4481

Closed KevinMulhern closed 3 months ago

KevinMulhern commented 3 months ago

Checks

Bug description

When opening modals, we lock scrolling on the screen and hide the scrollbar.

This works fine on larger screens. But the scroll bar is already hidden on mobiles (unless you are actively scrolling).

This is creating a layout shift when a modal is closed, demonstrated in this video:

https://github.com/TheOdinProject/theodinproject/assets/7963776/e28164a4-4b52-42b6-97eb-d3b81a78de0f

How to reproduce

  1. Sign in
  2. Upload a solution for one of the projects
  3. Visit your dashboard
  4. Open mobile / responsive design view from your dev tools
  5. Click edit on the solution you uploaded
  6. Close the modal
  7. 💥 the layout shifts

Expected behavior

  1. Sign in
  2. Upload a solution for one of the projects
  3. Visit your dashboard
  4. Open mobile / responsive design view from your dev tools
  5. Click edit on the solution you uploaded
  6. Close the modal
  7. The layout does not shift

What browsers are you seeing the problem on?

Chrome

What OS are you using?

MacOS

Discord Name

@KM

Additional Comments

We hide the the scrollbar by applying a Tailwind p-4 utility class to the document body here:

This likely only needs to be applied to screens above Tailwinds sm breakpoint. So changing to sm:p-4 might fix it.

BryanF1nes commented 3 months ago

May I be assigned.