WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 5f3006a

Browse files
fix(mfa): fix UI issue with MFA modal on mobile
Because: * The modal jumps on scroll This commit: * prevents the background from scrolling with overscroll-contain and makes scrolling work nicer * adds a story for modal to test out scrolling Closes FXA-12473
1 parent 023d828 commit 5f3006a

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

packages/fxa-settings/src/components/Settings/Modal/index.stories.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ModalToggle = ({ children }: ModalToggleProps) => {
2222
const [modalRevealed, showModal, hideModal] = useBooleanState(true);
2323
const onClick = useCallback(
2424
(ev: React.MouseEvent) => {
25-
ev.preventDefault();
25+
ev.stopPropagation();
2626
showModal();
2727
},
2828
[showModal]
@@ -85,6 +85,26 @@ export const WithConfirmButton = () => (
8585
</ModalToggle>
8686
);
8787

88+
export const WithLongContent = () => (
89+
<ModalToggle>
90+
{({ modalRevealed, hideModal }) =>
91+
modalRevealed && (
92+
<Modal
93+
headerId="some-id"
94+
descId="some-description"
95+
onConfirm={hideModal as () => void}
96+
onDismiss={hideModal}
97+
>
98+
<h2>This is a modal with long content.</h2>
99+
{Array.from({ length: 42 }, (_, i) => (
100+
<p key={i}>Scroll down to see more</p>
101+
))}
102+
</Modal>
103+
)
104+
}
105+
</ModalToggle>
106+
);
107+
88108
export const WithConfirmAndNoCancelButton = () => (
89109
<ModalToggle>
90110
{({ modalRevealed, hideModal }) =>

packages/fxa-settings/src/components/Settings/Modal/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ export const Modal = ({
6161
<Portal id="modal">
6262
<div
6363
data-testid={testid}
64-
className="flex flex-col justify-center fixed inset-0 z-50 w-full p-2 h-full bg-black/75"
64+
className="flex fixed inset-0 z-50 w-full p-2 bg-black/75 h-dvh overflow-y-auto overscroll-contain"
6565
>
6666
<div
6767
data-testid="modal-content-container"
6868
className={classNames(
69-
'max-w-120 bg-white mx-auto rounded-xl border border-transparent overflow-y-auto',
69+
'max-w-120 bg-white m-auto rounded-xl border border-transparent',
7070
className
7171
)}
7272
ref={modalInsideRef}

0 commit comments

Comments
 (0)