Primeng: Visible property to calendar

Created on 6 Feb 2017  路  6Comments  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[x ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Expected behavior
Provide an input/method for closing the calendar upon selecting a date.

What is the motivation / use case for changing the behavior?
Especially on mobile devices it's horrible UX since the datepicker takes up so much space on the screen. It's hard to close it manually.

new feature

Most helpful comment

You can create a viewchild and set the 'overlayVisible' property manually:

In your template add a template reference variable:

<p-calendar #myCalendar ... 

In your controller access the overlayVisible property:

@ViewChild('myCalendar') datePicker;

hideDatePicker(){
    this.datePicker.overlayVisible = false;
}

All 6 comments

And if I want to close the calendar manually? For example, when a resize event succeeds.

Thanks.

How close the calendar manually? When calendar is inside a pop up not close when a date is selected?

We can expose overlayVisible

You can create a viewchild and set the 'overlayVisible' property manually:

In your template add a template reference variable:

<p-calendar #myCalendar ... 

In your controller access the overlayVisible property:

@ViewChild('myCalendar') datePicker;

hideDatePicker(){
    this.datePicker.overlayVisible = false;
}

Did this used to work or was it just not tested with selectionMode="range"? There is a bug where if you use this property to "programmatically hide" the calendar, the overlay stays open and you can't click anything on the page (due to its z-index). See my stackblitz demo: https://vbwilqlo.github.stackblitz.io I will open an issue...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jisqaqov picture jisqaqov  路  3Comments

SchneMa picture SchneMa  路  3Comments

cyberrranger picture cyberrranger  路  3Comments

just-paja picture just-paja  路  3Comments

pchristou picture pchristou  路  3Comments