p-calendar onSelect won't trigger on first click

UI Components for Angular
Post Reply
Posts: 4
Joined: 16 Aug 2016, 16:13

21 Mar 2017, 13:50


I'm having a weird issue and I seem to be unable to solve it.

Also, I'm using PrimeNG 2.0.4.

I've made a custom component that includes a p-calendar and this component is called by another page/component. However date selection won't trigger on the first click.

So, my shared component is the following:

Code: Select all

<div class="formInput">
	<p-calendar class="mmkmaker" id="{{model.focusid}}" [(ngModel)]="model.value" dateFormat="dd/mm/yy" showAnim="slideDown"
	    (onSelect)="onSelect($event)" (onFocus)="onFocus()" [minDate]="getMinDate()"></p-calendar>

Code: Select all

import { Calendar } from 'primeng/primeng';
import { DateInputModel } from './date-input.model';
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import Moment from './../../loaders/momentLoader';

	moduleId: module.id,
	selector: "date-input",
	templateUrl: "index.html",
	styleUrls: ["date-input.css"],

export class DateInput {
	@Input() model: DateInputModel;
	@Output() change = new EventEmitter();
	@Output() focus = new EventEmitter();

	getMinDate() {
		return Moment().add(1, 'days').toDate();

	onSelect(event) {
	onFocus() {
This component is included into another (very) complex component, called like this:

Code: Select all

	<div id="descdate" class="mmStepPart" [ngClass]="{focusedFormPart: currentId === 'descdate'}" [hidden]="!mmkService.steps['descdate'].active"
		<div class="subtitlecenter">{{ "MISSIONS.MISSION_MAKER.DETAIL_ADD_END_DATE" | translate}}</div>
		<div class="note">{{ "MISSIONS.MISSION_MAKER.DETAIL_IF" | translate}}</div>
		<date-input [model]="mmkService.steps['descdate'].model" (focus)="goToId('descdate')" (change)="processDescription('descdate');"></date-input>
The onFocus method works flawlessly, however, the only thing that happens upon first click on the calendar is that the form will lose its pristine state (updating the css classes) but the value on the model won't change. That will only happen upon the second click.

What is going on here? Can anyone see any issue in this code?
Best Regards,
Celso Santos

Posts: 1
Joined: 13 Mar 2019, 14:06

13 Mar 2019, 14:13

I am also having the same issue. onselect method not triggered in first click and first click its going to another which i added for [minDate]. How to solve this issue?

Posts: 1
Joined: 18 Jun 2019, 07:32

18 Jun 2019, 07:34

I am also facing the same issue. The first click is triggering the getMindate of mindate attribute. Kindly advise

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests