-
Notifications
You must be signed in to change notification settings - Fork 561
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
[dialog] Opening dialog overrides padding on the body element #610
Comments
I'm not sure how simply we can override this.
@theKashey Any suggestions on your end? |
So that's a really hard part. I've spend quite a lot of time trying to understand that actually shall be done and "why", and at the end I didn't found an answer, that's why And actually I have a simple suggestion - In order to have a gap between |
Ordinarily this would be a fine solution. Something I would actually prefer honestly, but we are battling with previous folks decisions and almost zero confidence in being able to make that change to the application body styles. Is there no way I can affect the behavior of the various remove-scroll packages from the dialog? |
You can always add Another, probably good and working solution is to move existing styles "as-is" from the |
Just sharing my workaround here in case anyone has a need to override this as well. I passed i.g. implementation const LoginDialog = (props: LoginDialogProps) => {
const { onDismiss, ...delegated } = props;
useLockBodyScroll();
return (
<DialogOverlay onDismiss={onDismiss} dangerouslyBypassScrollLock {...delegated}>
<ContentBox aria-label="sign in dialog">
<Title>Sign in</Title>
<Button>Focusable</Button>
</ContentBox>
</DialogOverlay>
);
}; |
Unfortunately |
@theKashey Good catch, I found a better solution from usehooks-ts.com. This works on Safari (desktop & mobile). Here's a demo of it being used on https://congress.wiki/hr1-117 CleanShot.2022-05-19.at.09.57.32.mp4Implementation: const LoginDialog = (props: LoginDialogProps) => {
const { isOpen, onDismiss, ...delegated } = props;
// Lock body scroll when open
const [locked, setLocked] = useLockedBody();
useEffect(() => {
setLocked(!!isOpen);
}, [isOpen]);
return (
<DialogOverlay onDismiss={onDismiss} dangerouslyBypassScrollLock {...delegated}>
<ContentBox aria-label="sign in dialog">
<Title>Sign in</Title>
<Button>Focusable</Button>
</ContentBox>
</DialogOverlay>
);
}; |
🐛 Bug report
Current Behavior
When the dialog is open, react-remove-scroll via react-remove-scroll-bar, sets some css properties on the body. One of them is padding-top which is set to 0. We need to not do that for our page layout to not break.
We use a sticky masthead which the underlying content uses a padding top value on the body to not be obscured by the masthead.
When react-remove-scroll-bar removed the top padding, the top of the content is under the masthead and the bottom of the page jumps up.
https://share.getcloudapp.com/JruLNJ1j
Expected behavior
react-remove-scroll-bar does allow you to prevent or override some of these css properties. I should be able to pass dialog some control to prevent this from happening.
Suggested solution(s)
expose some react-remove-scroll-bar props to override the behavior.
Your environment
https://www.twilio.com/console/iot/supersim/network-access-profiles
The text was updated successfully, but these errors were encountered: