Skip to content

Commit 20e6257

Browse files
authored
fix(clerk-js): Avoid laggy ui when closing drawer after canceling subscription (#5711)
1 parent dab9acd commit 20e6257

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

.changeset/easy-zebras-wave.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Avoid laggy ui when closing drawer after canceling subscription.

packages/clerk-js/src/ui/components/Subscriptions/SubscriptionDetails.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
Span,
2222
Text,
2323
} from '../../customizables';
24-
import { Alert, Avatar, Drawer, ReversibleContainer } from '../../elements';
24+
import { Alert, Avatar, Drawer, ReversibleContainer, useDrawerContext } from '../../elements';
2525
import { InformationCircle } from '../../icons';
2626
import { formatDate, handleError } from '../../utils';
2727

@@ -34,6 +34,15 @@ export function SubscriptionDetails({
3434
const [showConfirmation, setShowConfirmation] = useState(false);
3535
const [isSubmitting, setIsSubmitting] = useState(false);
3636
const [cancelError, setCancelError] = useState<ClerkRuntimeError | ClerkAPIError | string | undefined>();
37+
38+
const { setIsOpen } = useDrawerContext();
39+
40+
const handleClose = () => {
41+
if (setIsOpen) {
42+
setIsOpen(false);
43+
}
44+
};
45+
3746
if (!subscription) {
3847
return null;
3948
}
@@ -48,6 +57,7 @@ export function SubscriptionDetails({
4857
.then(() => {
4958
setIsSubmitting(false);
5059
onSubscriptionCancel?.();
60+
handleClose();
5161
})
5262
.catch(error => {
5363
handleError(error, [], setCancelError);

packages/clerk-js/src/ui/contexts/components/Plans.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export const usePlansContext = () => {
174174
onSubscriptionCancel: () => {
175175
ctx.revalidate();
176176
onSubscriptionChange?.();
177-
clerk.__internal_closeSubscriptionDetails();
178177
},
179178
portalId:
180179
mode === 'modal'

0 commit comments

Comments
 (0)