Skip to content
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

Datepicker triggers ControlValueAccessor change without user interaction #6677

Open
rschlimmer opened this issue Aug 14, 2024 · 3 comments
Open

Comments

@rschlimmer
Copy link

Bug description:

The datepicker triggers the change event callback handler (e.g. ngModelChange) during component initialization.

Plunker/StackBlitz that reproduces the issue:

https://stackblitz.com/edit/1hchts-ei6y7y?file=src%2Fapp%2Fapp.component.ts

The provided StackBlitz renders two bsDatepicker that illustrate different initial model values. Both of their ngModelChange callback functions are immediately called without user interaction as seen in the console log. Additionally, the value provided by the event is strictly equal to the original model value despite being notified of a change. Lastly, clearing a datepicker that is currently assigned to a Date value triggers two change events; one notifying of the change to undefined and a second which re-notifies of the change to undefined.

This is a new issue since 18.0.0 of ngx-bootstrap. I believe the behavior change may have been introduced as an unintended side-effect of the fix for issue #6640 (pull-request #6641).

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: 18.0.2

Angular: 18.1.4

Bootstrap:

Build system: Angular CLI, System.js, webpack, starter seed:

Expected behavior

The datepicker ControlValueAccessor implementation should invoke the callback function passed to registerOnChange only when changed by the component via user interaction.

Registers a callback function that is called when the control's value changes in the UI.

https://angular.dev/api/forms/ControlValueAccessor#registerOnChange

@kamran3210
Copy link

I'm having a similar issue, since upgrading to v18.0.2, my project is getting stuck in infinite update loops in certain scenarios.

I've recreated the issue here: https://stackblitz.com/edit/stackblitz-starters-bznejv?file=src%2Fapp%2Fapp.component.html

@simfyz
Copy link

simfyz commented Aug 22, 2024

I'm having same issue after upgrading to v18.0.2. As of now downgrading to v18.0.0 to keep the app running.

@M4x3e3e
Copy link

M4x3e3e commented Sep 6, 2024

same issue for me, had to downgrade like @simfyz mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants