handled correct time slots
This commit is contained in:
parent
2fbd7462d5
commit
ea0c3b5ca7
@ -121,13 +121,19 @@ const TimePicker = ({ label, onChange, interval = 10, value,checkInTime,checkOut
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen && time && slotRefs.current[time]) {
|
if (isOpen) {
|
||||||
const selectedSlot = slotRefs.current[time];
|
const slots = generateTimeSlots();
|
||||||
selectedSlot.scrollIntoView({
|
const targetTime = slots.find(slot => slot.time === time && slot.isSelectable)
|
||||||
|
? time
|
||||||
|
: (slots.find(slot => slot.isSelectable)?.time || null);
|
||||||
|
|
||||||
|
if (targetTime && slotRefs.current[targetTime]) {
|
||||||
|
slotRefs.current[targetTime].scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "center",
|
block: "center",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, [isOpen, time]);
|
}, [isOpen, time]);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user