Skip to content

Commit 099d6b7

Browse files
Lock background scroll while modals are open (#1244)
Chakra 2.9 flipped the Modal preserveScrollBarGap default to true (chakra-ui/chakra-ui#8222), which maps to react-remove-scroll's removeScrollBar=false. That drops the body overflow:hidden lock, leaving the page scrollbar live and draggable behind the modal overlay. Set preserveScrollBarGap={false} on every Modal/Drawer/AlertDialog to restore the pre-2.10 hard scroll lock.
1 parent 6d0a4e2 commit 099d6b7

11 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/common/ConfirmDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const ConfirmDialog = ({
3838
isOpen
3939
leastDestructiveRef={leastDestructiveRef}
4040
onClose={() => callback(false)}
41+
preserveScrollBarGap={false}
4142
>
4243
<AlertDialogOverlay>
4344
<AlertDialogContent>

src/common/GenericDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const GenericDialog = ({
4747
size={size}
4848
returnFocusOnClose={returnFocusOnClose}
4949
finalFocusRef={finalFocusRef}
50+
preserveScrollBarGap={false}
5051
>
5152
<ModalOverlay>
5253
<ModalContent minWidth="560px" my="auto">

src/common/InputDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const InputDialog = <T,>({
7373
};
7474

7575
return (
76-
<Modal isOpen onClose={onCancel} size={size} finalFocusRef={finalFocusRef}>
76+
<Modal isOpen onClose={onCancel} size={size} finalFocusRef={finalFocusRef} preserveScrollBarGap={false}>
7777
<ModalOverlay>
7878
<ModalContent>
7979
<ModalHeader>

src/common/ProgressDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const ProgressDialog = ({
4242
onClose={doNothing}
4343
isCentered
4444
size={body ? "xl" : "md"}
45+
preserveScrollBarGap={false}
4546
>
4647
<ModalOverlay />
4748
<ModalContent>

src/serial/SerialHelp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const SerialHelpDialog = ({
4444
onClose={onClose}
4545
size="lg"
4646
finalFocusRef={finalFocusRef}
47+
preserveScrollBarGap={false}
4748
>
4849
<ModalOverlay>
4950
<ModalContent>

src/settings/LanguageDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const LanguageDialog = ({
5656
onClose={onClose}
5757
size="xl"
5858
finalFocusRef={finalFocusRef}
59+
preserveScrollBarGap={false}
5960
>
6061
<ModalOverlay>
6162
<ModalContent>

src/settings/SettingsDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const SettingsDialog = ({
3535
onClose={onClose}
3636
size="lg"
3737
finalFocusRef={finalFocusRef}
38+
preserveScrollBarGap={false}
3839
>
3940
<ModalOverlay>
4041
<ModalContent>

src/workbench/AboutDialog/AboutDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const AboutDialog = ({ isOpen, onClose, finalFocusRef }: AboutDialogProps) => {
8282
onClose={onClose}
8383
size="4xl"
8484
finalFocusRef={finalFocusRef}
85+
preserveScrollBarGap={false}
8586
>
8687
<ModalOverlay>
8788
<ModalContent>

src/workbench/FeedbackForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const FeedbackForm = ({
4747
onClose={onClose}
4848
size="2xl"
4949
finalFocusRef={finalFocusRef}
50+
preserveScrollBarGap={false}
5051
>
5152
<ModalOverlay>
5253
<ModalContent>

src/workbench/SideBarHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ const SideBarHeader = ({
143143
isOpen={searchModal.isOpen}
144144
onClose={handleModalClosed}
145145
size="lg"
146+
preserveScrollBarGap={false}
146147
>
147148
<ModalOverlay>
148149
<ModalContent

0 commit comments

Comments
 (0)