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

🐞 - tui-calendar-range, emitter itemChange not calling before valueChange #9878

Open
0ReC0 opened this issue Dec 2, 2024 · 0 comments
Open

Comments

@0ReC0
Copy link
Contributor

0ReC0 commented Dec 2, 2024

Reproduction url

https://stackblitz.com/edit/angular-uqjw4d?file=src%2Fapp%2Fcalendar%2Fcalendar.component.ts

Description

1. Problem

If you make a handler on itemChange, it is called after valueChange, although we first select the value from items, and only then we change based on that value.
Current behavior: valueChange -> itemChange
Expected behavior: itemChange -> valueChange
What's the problem: when processing values, valueChange always goes according to the previous value of itemChange, not the current value. Since valueChange is the main event, the main processing is done on it.

    <tui-calendar-range
        [items]="dayRangePeriods()"
        (valueChange)="onValueChange($event)"
        (itemChange)="onItemChange($event)"
    ></tui-calendar-range>

I have to insert crutches, because it is not very logical to transfer everything to itemChange, because itemChange event, as I understood, should refer to the selection of an item in the list range

  onValueChange(value: TuiDayRange | null) {
    // Hard workaround to sync events
    timer(0)
      .pipe(takeUntilDestroyed(this.destroyRef))
      .subscribe(() => {
        this.rangeChange.emit({
          dateFrom: value?.from.toJSON(),
          dateTo: value?.to.toJSON(),
          presetValue: this.selectedItemFromItemChange(),
        });
      });
  }

In stack blitz showed example "By changing the value, the filter is closed and the value is mapped to the outside of the component
When item is changed, the value is written to the signal to save the selected period."
The problem is that the value always goes with the old item in the valueChange handler.

Taiga UI version

33.89.0

Browser Used

Chrome

OS Used

macOS

@0ReC0 0ReC0 changed the title 🐞 - tui-calendar-range, emitter itemChange not calling before valueChange, also cant get access to 'name' field of TuiDayRangePeriod 🐞 - tui-calendar-range, emitter itemChange not calling before valueChange Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant