IgniteUI / igniteui-angular

Ignite UI for Angular is a complete library of Angular-native, Material-based Angular UI components with the fastest grids and charts, Pivot Grid, Dock Manager, Hierarchical Grid, and more.
https://www.infragistics.com/products/ignite-ui-angular
Other
572 stars 161 forks source link

IgxCalendar data-binding doesn't listen to external value changes for multi-select #9959

Closed baleeds closed 3 years ago

baleeds commented 3 years ago

Description

Two-way data binding [(ngModel)] doesn't work properly with the igx-calendar component in multi-selection mode. Additionally, setting the IgxCalendarComponent.value manually does nothing to update the internal state of selected dates.

Steps to reproduce

Here is a minimum example of the bug on StackBlitz 1) Using the linked stackblitz, select three dates on the calendar. The dates will appear below. 2) Click the "clear dates" button. Notice the dates are still selected on the calendar, even though the dates property is now empty. 3) Click another date on the calendar. Notice the dates property now contains all 4 dates that have ever been selected.

Result

The dates property is not being synced to the selected dates on the calendar.

Expected result

The calendar's dates should match the dates property.

dobromirts commented 3 years ago

Hello @baleeds , The igxCalendar is not supporting two way data binding for deselection of dates by specification. In addition this component exposes 'deselectDate' method for this purposes which ensures the correct deselection based on disabled dates and other scenarios. In the provided sample you can achieve this functionality by using it and all dates will be synced with the calendar.

baleeds commented 3 years ago

Thanks for the response. That solution will work for me 👍

Have you considered supporting full two-way binding? I feel it would be more consistent with other form controls in the IGX library, and in Angular as a whole.

If not, I would suggest that some changes be made to the documentation which outlines this information. Not using two-way binding to interact with a form control in Angular is a deviation from the pattern. Being able to do one-way binding with ngModel makes this even more confusing.

Thanks again, it's a great component!

ddincheva commented 3 years ago

@baleeds, Thank you for the feedback, we really appreciate it and will take it into account! We will update our current documentation and will discuss if it's possible to introduce two-way data binding as a new feature in one of our upcoming major versions.