Skip to content

Commit

Permalink
Fix hiding body scrollbar in Chrome extension and nested layers
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Dec 19, 2023
1 parent 21ceaf6 commit 9a6c414
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions .changelog/1811.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix hiding body scrollbar in Chrome extension and nested layers
7 changes: 6 additions & 1 deletion src/app/components/ResponsiveLayer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export function ResponsiveLayer(props: LayerExtendedProps) {
)

return (
<Layer {...props} ref={layerRef} style={{ overflowY: 'auto', ...props.style }}>
<Layer
{...props}
ref={layerRef}
className="fix-responsive-layer"
style={{ overflowY: 'auto', ...props.style }}
>
<Box
// Prevents Grommet flex overlap issue in smaller viewport
flex={{ shrink: 0, grow: 1 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ exports[`<AddContact /> should match snapshot 1`] = `
class="c2"
/>
<div
class="c3"
class="c3 fix-responsive-layer"
data-g-portal-id="0"
style="overflow-y: auto; width: 100%; max-width: none; min-height: min(550px, 90dvh);"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ exports[`<ImportAccountsSelectionModal /> should match snapshot 1`] = `
class="c2"
/>
<div
class="c3"
class="c3 fix-responsive-layer"
data-g-portal-id="0"
style="overflow-y: auto;"
>
Expand Down
21 changes: 21 additions & 0 deletions src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ html {
max-height: 16px;
}

/*
* Grommet and ResponsiveLayer do not handle nesting layers well:
* If user opens settings, clicks manage account (nested layer), and cancels:
* settings modal is still open, but `overflow: hidden` is removed from body.
* Workaround: set overflow hidden when any responsive layer exists.
*/
body:has(.fix-responsive-layer) {
overflow: hidden;
}
/*
* In chrome extension popup: `overflow: hidden` does not work on document.body,
* so main scrollbar is still displayed after modal tries to hide it. Workaround:
* change scrollbar width to 0 when any responsive layer exists.
*/
body:has(.fix-responsive-layer) {
scrollbar-width: none;
}
body:has(.fix-responsive-layer)::-webkit-scrollbar {
display: none;
}

/* Visually warn developers about sensitive input fields missing preventSavingInputsToUserData */
:is(input, textarea):is(
[type="password"], [name="password"], [name="privatekey"], [name="mnemonic"], #privatekey, #mnemonic
Expand Down

0 comments on commit 9a6c414

Please sign in to comment.