From a4a6b82a8c307c84a662760fb55978dc4c621821 Mon Sep 17 00:00:00 2001 From: Eben Eliason Date: Wed, 19 Jan 2022 10:47:11 -0800 Subject: [PATCH] [APT-1675] Don't scroll page on modal cancel --- src/components/Modal.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index 70ac8b7867..b0980aacc1 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -29,14 +29,17 @@ export const SubscriptionNoticeModal: React.FC = ({ handleCancelRequest, handleAcceptRequest, }) => { - const onRequestClose = () => { + const onRequestClose = (e) => { // If the user checked to never see this notice but subsequently cancels we will disregard their selection. We will // only stop showing this notice if they check the box and then proceed to GitHub - if(window.localStorage.getItem(DONT_SHOW_PRIVATE_GITHUB_WARNING_KEY)) { + if (window.localStorage.getItem(DONT_SHOW_PRIVATE_GITHUB_WARNING_KEY)) { window.localStorage.removeItem(DONT_SHOW_PRIVATE_GITHUB_WARNING_KEY) } - + handleCancelRequest() + + // prevent the browser from handling a Cancel button click and scrolling to top + e.preventDefault() } const gitHubRepoName = externalLink.match( @@ -86,7 +89,7 @@ export const SubscriptionNoticeModal: React.FC = ({ const setDontWarnMe = (event) => { event.stopPropagation() - if(!window.localStorage.getItem(DONT_SHOW_PRIVATE_GITHUB_WARNING_KEY)) { + if (!window.localStorage.getItem(DONT_SHOW_PRIVATE_GITHUB_WARNING_KEY)) { window.localStorage.setItem(DONT_SHOW_PRIVATE_GITHUB_WARNING_KEY, "true") } else { window.localStorage.removeItem(DONT_SHOW_PRIVATE_GITHUB_WARNING_KEY) @@ -117,7 +120,7 @@ export const SubscriptionNoticeModal: React.FC = ({
- onRequestClose()} href="#"> + onRequestClose(e)} href="#"> Cancel