Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/oauth-consent-mount-after-set-active.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Fix `<OAuthConsent />` rendering a blank page when reached through the redirect after completing `<SignIn />` or `<SignUp />`.
26 changes: 26 additions & 0 deletions packages/clerk-js/src/core/__tests__/clerk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,32 @@ describe('Clerk singleton', () => {
expect(mockSession.touch).toHaveBeenCalledWith({ intent: 'select_session' });
});

it('mounts OAuthConsent when mounted while navigating to redirectUrl', async () => {
mockClientFetch.mockReturnValue(
Promise.resolve({ signedInSessions: [mockSession], isEligibleForTouch: () => false }),
);
const mountComponent = vi.fn();
const mockClerkUICtor = vi.fn(function () {
return { ensureMounted: () => Promise.resolve({ mountComponent }) };
});

const sut = new Clerk(productionPublishableKey);
await sut.load({ ui: { ClerkUI: mockClerkUICtor } });
const node = document.createElement('div');
sut.navigate = vi.fn(async () => {
sut.mountOAuthConsent(node);
});

await sut.setActive({
session: mockSession as any as ActiveSessionResource,
redirectUrl: '/oauth-consent',
});

await waitFor(() => {
expect(mountComponent).toHaveBeenCalledWith(expect.objectContaining({ name: 'OAuthConsent', node }));
});
});

describe('with `touchSession` set to false', () => {
it('calls session.touch by default outside of focus window event', async () => {
mockSession.touch.mockReturnValue(Promise.resolve());
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ export class Clerk implements ClerkInterface {
};

public mountOAuthConsent = (node: HTMLDivElement, props?: __internal_OAuthConsentProps) => {
if (noUserExists(this)) {
if (this.user === null) {
if (this.#instanceType === 'development') {
throw new ClerkRuntimeError(warnings.cannotRenderOAuthConsentComponentWhenUserDoesNotExist, {
code: CANNOT_RENDER_USER_MISSING_ERROR_CODE,
Expand Down
Loading