Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 41c323a

Browse filesBrowse files
fix(ui): provide CardState to composed OrganizationProfileGeneralPanel default page (#9243)
1 parent 2466247 commit 41c323a
Copy full SHA for 41c323a

3 files changed

+33-1Lines changed: 33 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/ui': patch
3+
---
4+
5+
Fix `OrganizationProfileGeneralPanel` (from `@clerk/ui/experimental`) throwing "CardState not found" when opening the leave-organization or delete-organization confirmation in its default, no-children page mode. The panel now provides the same root `CardStateProvider` that a mounted `<OrganizationProfile />` supplies.
Collapse file

‎packages/ui/src/composed/OrganizationProfile/General.tsx‎

Copy file name to clipboardExpand all lines: packages/ui/src/composed/OrganizationProfile/General.tsx
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ function GeneralComposed({ children }: PropsWithChildren): ReactNode {
2626

2727
export function OrganizationProfileGeneralPanel({ children }: PropsWithChildren): ReactNode {
2828
if (!children) {
29-
return <OrganizationGeneralPage />;
29+
// Unlike AccountPage/SecurityPage, OrganizationGeneralPage does not self-wrap in a
30+
// CardStateProvider. Mounted <OrganizationProfile /> supplies one at its root, so the
31+
// leave/delete confirmation forms (useLeaveWithRevalidations -> useCardState) resolve it.
32+
// The composed panel is a standalone entry point, so it must provide the same root here.
33+
return (
34+
<CardStateProvider>
35+
<OrganizationGeneralPage />
36+
</CardStateProvider>
37+
);
3038
}
3139

3240
// The section confirmation forms (leave/delete) call useCardState(), so children must be wrapped
Collapse file

‎packages/ui/src/composed/__tests__/OrganizationProfileSections.test.tsx‎

Copy file name to clipboardExpand all lines: packages/ui/src/composed/__tests__/OrganizationProfileSections.test.tsx
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ describe('OrganizationProfile composed sections', () => {
135135
});
136136
});
137137

138+
describe('General — default page mode (no children)', () => {
139+
it('provides CardState so the leave-organization confirmation can open', async () => {
140+
const { wrapper, fixtures } = await createFixtures(f => {
141+
f.withOrganizations();
142+
f.withUser({ email_addresses: ['test@clerk.com'], organization_memberships: [{ name: 'TestOrg' }] });
143+
});
144+
145+
fixtures.clerk.organization?.getDomains.mockReturnValue(Promise.resolve({ data: [], total_count: 0 }));
146+
147+
const { userEvent } = render(<OrganizationProfileGeneralPanel />, { wrapper });
148+
149+
// Before the fix, LeaveOrganizationForm's useLeaveWithRevalidations() calls useCardState()
150+
// with no ancestor CardStateProvider and throws "CardState not found".
151+
await userEvent.click(await screen.findByRole('button', { name: /leave organization/i }));
152+
153+
await waitFor(() => expect(screen.getByRole('button', { name: /cancel/i })).toBeInTheDocument());
154+
});
155+
});
156+
138157
describe('General — section outside page', () => {
139158
it('useRequirePage throws when rendered outside a page component', async () => {
140159
const { wrapper, fixtures } = await createFixtures(f => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.