Skip to content

Commit

Permalink
fix: prevent parent drawers from closing when canceling nested drawers
Browse files Browse the repository at this point in the history
Ensure the "Cancel" button in nested drawers stops event propagation to avoid unintentionally closing parent drawers. Addresses unintended event bubbling within Vaul's drawer components. Has the same effect on Radix dialog components, although does not affect the UI behavior.
  • Loading branch information
unrenamed committed Nov 24, 2024
1 parent 019528f commit d71f579
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 15 deletions.
3 changes: 2 additions & 1 deletion apps/web/ui/modals/accept-invite-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ function AcceptInviteModal({
<div className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16">
<Button
text="Back to dashboard"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
router.push("/");
setShowAcceptInviteModal(false);
}}
Expand Down
5 changes: 4 additions & 1 deletion apps/web/ui/modals/add-bank-account-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ const AddBankAccountForm = ({ closeModal }: AddBankAccountFormProps) => {
text="Cancel"
className="h-9 w-fit"
disabled={isSubmitting || isExecuting}
onClick={closeModal}
onClick={(e) => {
e.stopPropagation();
closeModal();
}}
/>

<Button
Expand Down
5 changes: 4 additions & 1 deletion apps/web/ui/modals/deposit-funds-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ const DepositFundsForm = ({ closeModal }: { closeModal: () => void }) => {
text="Cancel"
className="h-9 w-fit"
disabled={isSubmitting || isExecuting}
onClick={closeModal}
onClick={(e) => {
e.stopPropagation();
closeModal();
}}
/>

<Button
Expand Down
8 changes: 6 additions & 2 deletions apps/web/ui/modals/link-builder/advanced-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ function AdvancedModal({
<button
type="button"
className="text-xs font-medium text-gray-700 transition-colors hover:text-gray-950"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
setValueParent("externalId", null, { shouldDirty: true });
setValueParent("identifier", null, { shouldDirty: true });
setShowAdvancedModal(false);
Expand All @@ -192,7 +193,10 @@ function AdvancedModal({
variant="secondary"
text="Cancel"
className="h-9 w-fit"
onClick={() => setShowAdvancedModal(false)}
onClick={(e) => {
e.stopPropagation();
setShowAdvancedModal(false)
}}
/>
<Button
type="submit"
Expand Down
6 changes: 4 additions & 2 deletions apps/web/ui/modals/link-builder/expiration-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ function ExpirationModal({
<button
type="button"
className="text-xs font-medium text-gray-700 transition-colors hover:text-gray-950"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
setValueParent("expiresAt", null, { shouldDirty: true });
setValueParent("expiredUrl", null, { shouldDirty: true });
setShowExpirationModal(false);
Expand All @@ -247,7 +248,8 @@ function ExpirationModal({
variant="secondary"
text="Cancel"
className="h-9 w-fit"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
reset();
setShowExpirationModal(false);
}}
Expand Down
6 changes: 4 additions & 2 deletions apps/web/ui/modals/link-builder/og-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ function OGModalInner({
<button
type="button"
className="text-xs font-medium text-gray-700 transition-colors hover:text-gray-950"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
setValueParent("proxy", false, { shouldDirty: true });
setShowOGModal(false);
}}
Expand All @@ -451,7 +452,8 @@ function OGModalInner({
variant="secondary"
text="Cancel"
className="h-9 w-fit"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
reset();
setShowOGModal(false);
}}
Expand Down
6 changes: 4 additions & 2 deletions apps/web/ui/modals/link-builder/password-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ function PasswordModalInner({
<button
type="button"
className="text-xs font-medium text-gray-700 transition-colors hover:text-gray-950"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
setValueParent("password", null, { shouldDirty: true });
setShowPasswordModal(false);
}}
Expand All @@ -191,7 +192,8 @@ function PasswordModalInner({
variant="secondary"
text="Cancel"
className="h-9 w-fit"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
reset();
setShowPasswordModal(false);
}}
Expand Down
6 changes: 4 additions & 2 deletions apps/web/ui/modals/link-builder/targeting-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ function TargetingModal({
<button
type="button"
className="text-xs font-medium text-gray-700 transition-colors hover:text-gray-950"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
setValueParent("ios", null, { shouldDirty: true });
setValueParent("android", null, { shouldDirty: true });
setValueParent("geo", null, { shouldDirty: true });
Expand All @@ -382,7 +383,8 @@ function TargetingModal({
variant="secondary"
text="Cancel"
className="h-9 w-fit"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
reset();
setShowTargetingModal(false);
}}
Expand Down
3 changes: 2 additions & 1 deletion apps/web/ui/modals/link-builder/utm-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ function UTMModalInner({ setShowUTMModal }: UTMModalProps) {
variant="secondary"
text="Cancel"
className="h-9 w-fit"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
reset();
setShowUTMModal(false);
}}
Expand Down
3 changes: 2 additions & 1 deletion apps/web/ui/modals/link-qr-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ function LinkQRModalInner({
variant="secondary"
text="Cancel"
className="h-9 w-fit"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
setShowLinkQRModal(false);
}}
/>
Expand Down

0 comments on commit d71f579

Please sign in to comment.