From 6cecfb8e0d3523a2f2e7ed20c0568d777454a649 Mon Sep 17 00:00:00 2001 From: dorilama Date: Tue, 11 Mar 2025 09:49:45 +0000 Subject: [PATCH 1/3] fix(vue): add check for clerk.value in UseSessionList composable --- .changeset/seven-walls-drive.md | 5 +++++ packages/vue/src/composables/useSessionList.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/seven-walls-drive.md diff --git a/.changeset/seven-walls-drive.md b/.changeset/seven-walls-drive.md new file mode 100644 index 00000000000..792567cd99e --- /dev/null +++ b/.changeset/seven-walls-drive.md @@ -0,0 +1,5 @@ +--- +'@clerk/vue': patch +--- + +fix UsesessionList bug. When `clientCtx` is defined `clerk` can be `null` and throw when trying to access `clerk.value.setActive`. Added a condition to return the default values also when `clerk.value` is `null`. diff --git a/packages/vue/src/composables/useSessionList.ts b/packages/vue/src/composables/useSessionList.ts index 4ea4615437b..d6c2692fc12 100644 --- a/packages/vue/src/composables/useSessionList.ts +++ b/packages/vue/src/composables/useSessionList.ts @@ -35,14 +35,14 @@ export const useSessionList: UseSessionList = () => { const { clerk, clientCtx } = useClerkContext(); const result = computed(() => { - if (!clientCtx.value) { + if (!clientCtx.value || !clerk.value) { return { isLoaded: false, sessions: undefined, setActive: undefined }; } return { isLoaded: true, sessions: clientCtx.value.sessions, - setActive: clerk.value!.setActive, + setActive: clerk.value.setActive, }; }); From b5d887174d26f05083f7fb9182f4ec951e0dc406 Mon Sep 17 00:00:00 2001 From: dorilama Date: Tue, 11 Mar 2025 17:58:33 +0000 Subject: [PATCH 2/3] fix(vue): set initial value of `clientCtx` to `undefined` --- .changeset/fuzzy-pillows-doubt.md | 5 +++++ packages/vue/src/composables/useSessionList.ts | 4 ++-- packages/vue/src/plugin.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/fuzzy-pillows-doubt.md diff --git a/.changeset/fuzzy-pillows-doubt.md b/.changeset/fuzzy-pillows-doubt.md new file mode 100644 index 00000000000..5123d53efd8 --- /dev/null +++ b/.changeset/fuzzy-pillows-doubt.md @@ -0,0 +1,5 @@ +--- +'@clerk/vue': patch +--- + +updating the initial value of `clientCtx` to `undefined` as requested [here](https://github.com/clerk/javascript/pull/5324#discussion_r1989445357) diff --git a/packages/vue/src/composables/useSessionList.ts b/packages/vue/src/composables/useSessionList.ts index d6c2692fc12..4ea4615437b 100644 --- a/packages/vue/src/composables/useSessionList.ts +++ b/packages/vue/src/composables/useSessionList.ts @@ -35,14 +35,14 @@ export const useSessionList: UseSessionList = () => { const { clerk, clientCtx } = useClerkContext(); const result = computed(() => { - if (!clientCtx.value || !clerk.value) { + if (!clientCtx.value) { return { isLoaded: false, sessions: undefined, setActive: undefined }; } return { isLoaded: true, sessions: clientCtx.value.sessions, - setActive: clerk.value.setActive, + setActive: clerk.value!.setActive, }; }); diff --git a/packages/vue/src/plugin.ts b/packages/vue/src/plugin.ts index b019697a929..e2485a2d0ba 100644 --- a/packages/vue/src/plugin.ts +++ b/packages/vue/src/plugin.ts @@ -36,7 +36,7 @@ export const clerkPlugin: Plugin = { const clerk = shallowRef(null); const resources = ref({ - client: {} as ClientResource, + client: undefined as unknown as ClientResource, session: undefined, user: undefined, organization: undefined, From 7517f9cf5c26f02e14a51643d6fca7d0074adda4 Mon Sep 17 00:00:00 2001 From: dorilama Date: Tue, 11 Mar 2025 20:21:52 +0000 Subject: [PATCH 3/3] fix: update changelog --- .changeset/fuzzy-pillows-doubt.md | 2 +- .changeset/seven-walls-drive.md | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 .changeset/seven-walls-drive.md diff --git a/.changeset/fuzzy-pillows-doubt.md b/.changeset/fuzzy-pillows-doubt.md index 5123d53efd8..f6cbd212f61 100644 --- a/.changeset/fuzzy-pillows-doubt.md +++ b/.changeset/fuzzy-pillows-doubt.md @@ -2,4 +2,4 @@ '@clerk/vue': patch --- -updating the initial value of `clientCtx` to `undefined` as requested [here](https://github.com/clerk/javascript/pull/5324#discussion_r1989445357) +Bug fix: Update the initial value of `clientCtx` to `undefined` to correctly infer that `clerk` is defined.(https://github.com/clerk/javascript/pull/5324#discussion_r1989445357) diff --git a/.changeset/seven-walls-drive.md b/.changeset/seven-walls-drive.md deleted file mode 100644 index 792567cd99e..00000000000 --- a/.changeset/seven-walls-drive.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@clerk/vue': patch ---- - -fix UsesessionList bug. When `clientCtx` is defined `clerk` can be `null` and throw when trying to access `clerk.value.setActive`. Added a condition to return the default values also when `clerk.value` is `null`.