diff --git a/src/form/Checkbox/Checkbox.story.tsx b/src/form/Checkbox/Checkbox.story.tsx
index a4850374..5288ce64 100644
--- a/src/form/Checkbox/Checkbox.story.tsx
+++ b/src/form/Checkbox/Checkbox.story.tsx
@@ -1,5 +1,7 @@
import React, { Fragment, useState } from 'react';
import { Checkbox } from './Checkbox';
+import { Dialog, useDialog } from '@/layers/Dialog';
+import { Button } from '@/elements/Button';
export default {
title: 'Components/Form/Checkbox',
@@ -158,3 +160,32 @@ export const CustomLabel = () => {
/>
);
};
+
+export const WithDialog = () => {
+ const { isOpen, setOpen } = useDialog();
+ const [checked, setChecked] = useState(true);
+
+ return (
+
+
+
+
+
+
+ );
+};
diff --git a/src/form/Checkbox/Checkbox.tsx b/src/form/Checkbox/Checkbox.tsx
index 373ae6ce..40f1140a 100644
--- a/src/form/Checkbox/Checkbox.tsx
+++ b/src/form/Checkbox/Checkbox.tsx
@@ -3,7 +3,8 @@ import React, {
forwardRef,
LegacyRef,
ReactNode,
- useCallback
+ useCallback,
+ useEffect
} from 'react';
import { motion, useMotionValue, useTransform } from 'framer-motion';
import { twMerge } from 'tailwind-merge';
@@ -121,6 +122,12 @@ export const Checkbox: FC = forwardRef(
const pathLength = useMotionValue(0);
const opacity = useTransform(pathLength, [0.05, 0.15], [0, 1]);
+ useEffect(() => {
+ // If the checkbox is inside a dialog, the animation will not work.
+ // This is a workaround to force the animation to work.
+ pathLength.set(checked ? 1 : 0);
+ }, [checked, pathLength]);
+
const checkVariants = {
pressed: (isChecked: boolean) => ({ pathLength: isChecked ? 0.85 : 0.3 }),
checked: { pathLength: 1 },
@@ -177,7 +184,7 @@ export const Checkbox: FC = forwardRef(
}}
>
= forwardRef(
/>
{intermediate ? (
) : (
= forwardRef(
checked && theme.check.checked
)}
variants={checkVariants}
+ initial={checked ? 'checked' : 'unchecked'}
style={{ pathLength, opacity }}
custom={checked}
/>
diff --git a/src/form/Input/DebouncedInput/DebouncedInput.tsx b/src/form/Input/DebouncedInput/DebouncedInput.tsx
index 7b0643f6..3e71c2b9 100644
--- a/src/form/Input/DebouncedInput/DebouncedInput.tsx
+++ b/src/form/Input/DebouncedInput/DebouncedInput.tsx
@@ -13,8 +13,7 @@ export const DebouncedInput = forwardRef(
{ debounce = 100, value, onChange, onValueChange, ...rest },
ref: Ref
) => {
- // eslint-disable-next-line no-undef
- const timeoutRef = useRef(null);
+ const timeoutRef = useRef | null>(null);
const [internalValue, setInternalValue] = useState<
string | number | readonly string[]
>(value);