Skip to content

Modal: rounding error causing "scrolling" className not to be applied #1867

@lifehackett

Description

@lifehackett

Steps

Mount a modal to the body. Note, this doesn't happen for all modals in all contexts so I'm not 100% sure of the steps to reproduce

Expected Result

The modal will fill the entire screen

Actual Result

At certain heights the calculation to apply the scrolling classname is off by a few decimal points causing the classname not to get applied. This means the inline style of margin-top get applied causing the modal to shift upwards.

Version

"semantic-ui-react": "0.71.0"

Testcase

https://gfycat.com/gifs/detail/HarmoniousImpureBoar
(Hmmm, first time submitting a video. Didn't turn out as well as I had hoped. Let me know if you'd like me to try again. Basically it is just showing the effect on the screen and the rounding issue I mentioned)

My understanding is that getBoundingClientRect returns the actual rendered height down to the decimal whereas innerHeight returns the height rounded to the nearest integer. What do you think about switching the implementation to either (at least for the conditional application of scrolling) to avoid the rounding issue.

  1. this.ref.clientHeight >= window.innerHeight
  2. Math.round(height) >= window.innerHeight

Are there any known CSS workarounds that I can apply to the Modal content to avoid this issue?

Thanks,
Conor

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions