-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: Can we remove the screen jump when modals are shown? #14442
Comments
@wkeese This was added in #3237 to fix the defect of content behind the modal being scrollable. Is there a reliable way to get the scrollbar width on a given browser and/or OS? If so we could apply a margin-right of that value to avoid the reflow. You could do this in your application with custom styles for now. It may be complicated to support platforms that allow hiding the scrollbars, such as MacOS. |
I think this is one of those problems that can't be solved just by CSS. You can do this in Javascript:
Note also that the scrollbar might be on the left side instead of the right side. Ideally, you would use a selector the
PS: Oh if you are writing Javascript anyway then you can do |
Right, but I don't know if there's a way to detect if the user agent is including the scrollbar as part of the clientWidth or not. IIRC on mac it only does if the setting for "always show scrollbars" is selected in the system settings. If there's not a reliable way to detect this, we may not be able to add a solution that works for all platforms. |
Question for Carbon
When displaying a modal, the scroll bar on
<body>
is hidden by the following CSS:Since this affects the width of the browser window (at least on Windows), it causes either:
Modal.js and ComposedModal.js both toggle this CSS class. Or at least, they both have code to toggle the class; there seems to be a bug in Modal.js where that code doesn't run correctly.
You can see it clearly from the "Launch modal" button on https://react.carbondesignsystem.com/?path=/docs/components-composedmodal--overview, especially if you add content to the
<body>
that will reflow on browser width change.This CSS was obviously added intentionally... it traces back to 15d5fc8 and is still there today (https://github.com/carbon-design-system/carbon/blob/main/packages/styles/scss/components/modal/_modal.scss#L436).
However, it's unclear why it was added and whether or not it's still needed.
Given the negative side effects of hiding the scrollbar, do we need that CSS?
Code of Conduct
The text was updated successfully, but these errors were encountered: