Skip to content

Commit

Permalink
chore: temp commit with timeouts will be squashed
Browse files Browse the repository at this point in the history
  • Loading branch information
edleeks87 committed Sep 19, 2024
1 parent 47189ec commit 1ed9fd1
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 9 deletions.
22 changes: 19 additions & 3 deletions src/components/date/date.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export const DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(
);
const isInitialValue = useRef(true);
const pickerTabGuardId = useRef(guid());
const timerRef = useRef<NodeJS.Timeout | null>(null);

const computeInvalidRawValue = (inputValue: string) =>
allowEmptyValue && !inputValue.length ? inputValue : null;
Expand Down Expand Up @@ -293,7 +294,12 @@ export const DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(
isBlurBlocked.current = false;

if (!open && !alreadyFocused.current) {
setOpen(true);
if (timerRef.current) {
clearTimeout(timerRef.current);
}
timerRef.current = setTimeout(() => {
setOpen(true);
}, 0);
} else {
alreadyFocused.current = false;
}
Expand Down Expand Up @@ -351,9 +357,19 @@ export const DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(

if (type !== "text") {
alreadyFocused.current = true;
setOpen((prev) => !prev);
if (timerRef.current) {
clearTimeout(timerRef.current);
}
timerRef.current = setTimeout(() => {
setOpen((prev) => !prev);
}, 0);
} else if (!open) {
setOpen(true);
if (timerRef.current) {
clearTimeout(timerRef.current);
}
timerRef.current = setTimeout(() => {
setOpen(true);
}, 0);
}
};

Expand Down
Loading

0 comments on commit 1ed9fd1

Please sign in to comment.