I'm using primereact version 6.2.1, While using the calendar from primereact i have enabled the option for showTime. This brings up a datePicker with an overlay blocking out the rest of the webpage. All this works fine. Except after a date and time are picked the only way to close the datePicker is to click somewhere else on the browser. Is there a way to close it manually ?
Asked
Active
Viewed 738 times
1
-
Please provide enough code so others can better understand or reproduce the problem. – Community Mar 02 '22 at 02:50
2 Answers
1
import React, { useRef } from 'react';
import { Calendar } from 'primereact/calendar';
const CustomCalendar = (props) => {
const cal = useRef(null);
const handleClose = () => {
cal.current.hideOverlay()
// if you're using touchUI option you have to hade it also ;)
cal.current.touchUIMask.style.display = "none";
};
return <Calendar
ref={cal}
{...props}
footerTemplate={(e) => <div className='footer-calendar'><button onClick={handleClose}>Done</button></div>}
/>
}
You can close overlay manually using ref, you can check this link sandbox
or check the github link for more options github

yahyawi AB
- 11
- 3
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 11 '22 at 06:04
0
If you get a ref to your Calendar
you can call calendarRef.current.hideOverlay();
I also opened this ticket: https://github.com/primefaces/primereact/issues/2685
Submitted this PR: https://github.com/primefaces/primereact/pull/2687

Melloware
- 10,435
- 2
- 32
- 62