Skip to content

Commit

Permalink
Add default "Cancel" text for cancel buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
fnwbr committed Feb 28, 2024
1 parent 73d237d commit 3bb2792
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/UI/shadcn/DialogDrawer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { useTranslation } from 'react-i18next';

import { cn, useMediaQuery } from '@/lib/utils';
import { Drawer, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader } from '@/components/UI/shadcn/Drawer';
Expand Down Expand Up @@ -51,13 +52,14 @@ const DrawerDialogHeader = React.forwardRef(({ className, children, ...props },
DrawerDialogHeader.displayName = 'DrawerDialogHeader';

const DrawerDialogFooter = React.forwardRef(({ className, cancelLabel, children, ...props }, ref) => {
const { t } = useTranslation();
const isDesktop = useMediaQuery(isDesktopMediaQuery);

if (isDesktop) {
return (
<DialogFooter className={className} ref={ref} {...props}>
<DialogClose ref={ref} asChild>
<Button variant="outline">{cancelLabel}</Button>
<Button variant="outline">{cancelLabel || t('Cancel')}</Button>
</DialogClose>
{children}
</DialogFooter>
Expand All @@ -68,7 +70,7 @@ const DrawerDialogFooter = React.forwardRef(({ className, cancelLabel, children,
<DrawerFooter className={cn('px-0', props.className)} ref={ref} {...props}>
{children}
<DrawerClose ref={ref} asChild>
<Button variant="outline">{cancelLabel}</Button>
<Button variant="outline">{cancelLabel || t('Cancel')}</Button>
</DrawerClose>
</DrawerFooter>
);
Expand Down

0 comments on commit 3bb2792

Please sign in to comment.