Skip to content

[Date picker] ValueChanged events are fired mutiple times in date picker #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
valadzhov opened this issue Oct 22, 2024 · 2 comments
Open
Assignees
Labels

Comments

@valadzhov
Copy link

Description

The ValueChange event is fired when the value is changed and again when the date picker loses focus.

Steps to reproduce

  1. Download and start the attached sample.
  2. Change the date and pay attention to the counter which represents the number of time the ValueChange event is fired.
  3. The counter is incremented.
  4. Click outside the date picker - the counter is incremented again.

Result

The ValueChange event is fired twice while it should be only once.

Expected result

The ValueChange event should be fired only once (when changing the date?).

Attachments

Attach a sample if available, and screenshots, if applicable.
date-picker-dev_Blazor-2-date-pickers.zip

@MayaKirova
Copy link

@valadzhov @dkamburov The issue is due to Blazor serializing/de-serializing the new set date value when you select something from the calendar as it needs to sync it to the server instance of the component so that the Value prop of the server component is up-to date.

As a result the following check when you blur fails:
https://github.com/IgniteUI/igniteui-webcomponents/blob/master/src/components/date-time-input/date-time-input.ts#L624

Since after deserialization on the client, this value is no longer the same object ref, hence the date input will emit a change event for it.

Not much we can do about it from the Blazor side. What I can suggest is maybe improve the check on the wc component to compare whether the date value is actually the same, rather than comparing the date object refs. Since currently even if you input the same date multiple times, it would raise a change event each time. For example, if you type in “11/11/1111” and blur and then repeat the same multiple times it will always trigger the change event on blur even though the dates represent the same time and there is no actual change.

@dkamburov
Copy link

@rkaraivanov fyi

@valadzhov valadzhov closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2024
@valadzhov valadzhov reopened this Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants