Skip to content

Commit edf491e

Browse files
SignezSharglutDev
authored andcommitted
front: remove popover-related redundant code in DatePicker
Signed-off-by: Stanislas Signoud (Signez) <signez@stanisoft.net>
1 parent c5f0b23 commit edf491e

3 files changed

Lines changed: 1 addition & 14 deletions

File tree

front/ui/ui-core/src/components/DatePicker/useDatePicker.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useState, useRef, useEffect } from 'react';
22

3-
import useOutsideClick from '../../hooks/useOutsideClick';
43
import type { StatusWithMessage } from '../StatusMessage';
54
import type { DatePickerProps } from './DatePicker';
65
import {
@@ -23,17 +22,6 @@ export default function useDatePicker(datePickerProps: DatePickerProps) {
2322
const calendarPickerRef = useRef<HTMLDivElement>(null);
2423
const inputRef = useRef<HTMLInputElement>(null);
2524

26-
useOutsideClick(calendarPickerRef, (e) => {
27-
// Do not close the picker if any children in input wrapper is clicked.
28-
// This wrapper include, the input itself, the trailing content (which contains the calendar icon) and the leading content
29-
if (
30-
inputRef.current &&
31-
inputRef.current.parentElement?.parentElement?.contains(e.target as Node)
32-
)
33-
return;
34-
setShowPicker(false);
35-
});
36-
3725
const handleInputClick = () => {
3826
if (isRangeMode) {
3927
setShowPicker(true);

front/ui/ui-core/src/components/InputPopover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const InputPopover = ({
3434
popoverRef.current.showPopover();
3535
calculatePosition();
3636
}
37-
}, [isOpen, modalRef, calculatePosition]);
37+
}, [isOpen, calculatePosition]);
3838

3939
useOutsideClick(popoverRef, onClose);
4040

front/ui/ui-core/src/hooks/usePopoverPosition.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const usePopoverPosition = (
3232
}, [inputRef, popoverRef, verticalOffset]);
3333

3434
useEffect(() => {
35-
calculatePosition();
3635
const handleResize = () => calculatePosition();
3736
window.addEventListener('resize', handleResize);
3837
return () => window.removeEventListener('resize', handleResize);

0 commit comments

Comments
 (0)