Skip to content

Commit 223a5fc

Browse files
Ephemnikosdouvlis
andauthored
fix(ui): Fix Safari sign-in bugs (#7877)
Co-authored-by: Nikos Douvlis <nikosdouvlis@gmail.com>
1 parent 061c6c4 commit 223a5fc

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

.changeset/yummy-rats-cross.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/ui': patch
3+
---
4+
5+
Fix Safari sign-in redirect not completing when using OTP or impersonation.

packages/ui/src/contexts/components/SessionTasks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { buildTaskUrl, getTaskEndpoint } from '@clerk/shared/internal/clerk-js/sessionTasks';
2+
import { windowNavigate } from '@clerk/shared/internal/clerk-js/windowNavigate';
23
import { useClerk } from '@clerk/shared/react';
34
import type { DecorateUrl, SessionResource } from '@clerk/shared/types';
45
import { createContext, useContext } from 'react';
@@ -43,7 +44,7 @@ export const useSessionTasksContext = (): SessionTasksContextType => {
4344
// If decorateUrl modified the URL (Safari ITP fix), do a full page navigation
4445
// The touch endpoint URL will be an absolute URL starting with http:// or https://
4546
if (decoratedUrl !== redirectUrlComplete && /^https?:\/\//.test(decoratedUrl)) {
46-
window.location.href = decoratedUrl;
47+
windowNavigate(decoratedUrl);
4748
return;
4849
}
4950

packages/ui/src/contexts/components/SignIn.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { SIGN_IN_INITIAL_VALUE_KEYS } from '@clerk/shared/internal/clerk-js/cons
22
import { RedirectUrls } from '@clerk/shared/internal/clerk-js/redirectUrls';
33
import { getTaskEndpoint } from '@clerk/shared/internal/clerk-js/sessionTasks';
44
import { buildURL } from '@clerk/shared/internal/clerk-js/url';
5+
import { windowNavigate } from '@clerk/shared/internal/clerk-js/windowNavigate';
56
import { useClerk } from '@clerk/shared/react';
67
import type { DecorateUrl, SessionResource } from '@clerk/shared/types';
78
import { isAbsoluteUrl } from '@clerk/shared/url';
@@ -140,7 +141,7 @@ export const useSignInContext = (): SignInContextType => {
140141
// If decorateUrl modified the URL (Safari ITP fix), do a full page navigation
141142
// The touch endpoint URL will be an absolute URL starting with http:// or https://
142143
if (decoratedUrl !== redirectUrl && /^https?:\/\//.test(decoratedUrl)) {
143-
window.location.href = decoratedUrl;
144+
windowNavigate(decoratedUrl);
144145
return;
145146
}
146147

packages/ui/src/contexts/components/SignUp.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { SIGN_UP_INITIAL_VALUE_KEYS } from '@clerk/shared/internal/clerk-js/cons
22
import { RedirectUrls } from '@clerk/shared/internal/clerk-js/redirectUrls';
33
import { getTaskEndpoint } from '@clerk/shared/internal/clerk-js/sessionTasks';
44
import { buildURL } from '@clerk/shared/internal/clerk-js/url';
5+
import { windowNavigate } from '@clerk/shared/internal/clerk-js/windowNavigate';
56
import { useClerk } from '@clerk/shared/react';
67
import type { DecorateUrl, SessionResource } from '@clerk/shared/types';
78
import { isAbsoluteUrl } from '@clerk/shared/url';
@@ -135,7 +136,7 @@ export const useSignUpContext = (): SignUpContextType => {
135136
// If decorateUrl modified the URL (Safari ITP fix), do a full page navigation
136137
// The touch endpoint URL will be an absolute URL starting with http:// or https://
137138
if (decoratedUrl !== redirectUrl && /^https?:\/\//.test(decoratedUrl)) {
138-
window.location.href = decoratedUrl;
139+
windowNavigate(decoratedUrl);
139140
return;
140141
}
141142

0 commit comments

Comments
 (0)