Skip to content

dateChange event of nb-calendar is emitting more that one date #2716

Open
@titusfx

Description

@titusfx

Issue type

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

  • [x ] bug report
  • feature request

Issue description

Current behavior:
I'm using a simple nb-calendar in a dialog, I notice, that if I: Open the calendar and click outside the dialog (this close the dialog and calendar) And I repeat the process, lets say 3 times more. When I select the date it will emit the date 4 times. ( 3 times that I cancel and the time I cancel)

I believe, that is a subscription that keeps opened and should be close, when I select the date, all the subscriptions trigger and that's why I receive 4 emitis

Expected behavior:

Emit once

Steps to reproduce:
Im using a simple nb-calendar, I notice, that if I: Open the calendar and click outside (this close the calendar) And I repeate the process, lets say 3 times more. When I select the date it will emit the date 4 times. ( 3 times that I cancel and the time I cancel)

Related code:

<nb-calendar size="small" (dateChange)="dateChange($event)" [date]="pickerCalendarAction.selectedDate" [dayCellComponent]="tabCacheService.dayCellComponent" [monthCellComponent]="tabCacheService.monthCellComponent" [yearCellComponent]="tabCacheService.yearCellComponent">
</nb-calendar>

a service

dateChange(selectedDate: Date) {
    this.pickerCalendarAction.changedDate$.next(selectedDate);
  }

changedDate$ is emitting 4 values ( in the example I gave)

Other information:

npm, node, OS, Browser

<!--
Node, npm: `node --version` and `npm --version`
OS: Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
Browser: Chrome/Safari/Firefox/etc?
-->

Angular, Nebular

<!--
Check your `package-lock.json` or locate a `package.json` in the `node_modules` folder.
-->

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions