Skip to content

Commit 0a44054

Browse files
fix: tab switching without URL change for email check redirect
Prevent URL navigation when handleEmailCheckComplete redirects to different page. Instead, use controlled Tabs with activeKey and redirectTo state to switch tabs. This fixes back button behavior where users would see incorrect page content. - Shadow selectedPage with computed value using redirectTo - Use activeKey instead of defaultActiveKey for controlled Tabs - Clear redirectTo on route change or manual tab selection
1 parent d02d8e1 commit 0a44054

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/logistration/Logistration.jsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { backupRegistrationForm } from '../register/data/actions';
3636
import ResetPasswordSuccess from '../reset-password/ResetPasswordSuccess';
3737

3838
const Logistration = (props) => {
39-
const { selectedPage, tpaProviders, showEmailCheck } = props;
39+
const { selectedPage: selectedPageProp, tpaProviders, showEmailCheck } = props;
4040
const tpaHint = getTpaHint();
4141
const {
4242
providers, secondaryProviders,
@@ -48,6 +48,7 @@ const Logistration = (props) => {
4848
const navigate = useNavigate();
4949
const disablePublicAccountCreation = getConfig().ALLOW_PUBLIC_ACCOUNT_CREATION === false;
5050
const hideRegistrationLink = getConfig().SHOW_REGISTRATION_LINKS === false;
51+
const selectedPage = redirectTo ? `/${redirectTo}` : selectedPageProp;
5152

5253
useEffect(() => {
5354
const authService = getAuthService();
@@ -62,6 +63,10 @@ const Logistration = (props) => {
6263
}
6364
}, [navigate, disablePublicAccountCreation]);
6465

66+
useEffect(() => {
67+
setRedirectTo(null);
68+
}, [selectedPageProp]);
69+
6570
const handleInstitutionLogin = (e) => {
6671
sendTrackEvent('edx.bi.institution_login_form.toggled', { category: 'user-engagement' });
6772
if (typeof e === 'string') {
@@ -84,6 +89,7 @@ const Logistration = (props) => {
8489
} else if (tabKey === REGISTER_PAGE) {
8590
props.backupLoginForm();
8691
}
92+
setRedirectTo(null);
8793
setKey(tabKey);
8894
};
8995

@@ -103,13 +109,9 @@ const Logistration = (props) => {
103109
return !!provider;
104110
};
105111

106-
const handleEmailCheckComplete = (redirectTo, email, errorCode) => {
112+
const handleEmailCheckComplete = (targetRedirect, email, errorCode) => {
107113
props.emailCheckComplete(email, errorCode);
108-
setRedirectTo(redirectTo);
109-
const targetPage = redirectTo === 'login' ? LOGIN_PAGE : REGISTER_PAGE;
110-
if (selectedPage !== targetPage) {
111-
navigate(updatePathWithQueryParams(targetPage));
112-
}
114+
setRedirectTo(targetRedirect);
113115
};
114116

115117
const activationMsgType = getActivationStatus();

0 commit comments

Comments
 (0)