igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

igx-slider - can't reflect Reactive form's value when dynamically changing maxValue.

Open tkiryu opened this issue 8 years ago • 1 comments

Description

This is related to #920.

As a workaround for #920, I'm binding upperBound as well as maxValue.

Then, another issue came up. igx-slider can't bind Reactive form's value.

Steps to reproduce

  1. Go to https://stackblitz.com/edit/igx-slider-issue2.
  2. Click "Set Value: 50" button.

Result

The upper igx-slider works well. But the lower one can't reflect Reactive form's value.

Expected result

igx-slider should reflect Reactive form's value.

By the way, here is a scenario what I want to achieve with igx-slider.

  1. There is a igx-grid.
  2. Click a cell, then, open igx-dialog and pass the cell(or row) data to the dialog.
  3. The dialog has a form including igx-slider.
  4. The data is bound to the form via ReactiveForm.
  5. That's why igx-slider's maxValue varies according to the passed data.

tkiryu avatar Apr 06 '18 07:04 tkiryu

This behavior is not really a bug. In the sample you have provided, in the button click event handler you are updating both, the model property to which slider's upperBound input is bound and the form control value, i.e our slider's value. The problem comes from the fact that upperBound input is updated after the value input while the internal implementation of the value input depends on that upperBound. Therefore the value input is not set correctly. To solve this problem, I would suggest wrapping the patchValue method in a timeout:

  setValue() {
    this.maxValue = 100;

    setTimeout(() => {
      this.form.patchValue({
        value1: 50,
        value2: 50
      });
    });
  }

....or just using separate buttons for updating the the data and the form models.

SAndreeva avatar May 02 '18 13:05 SAndreeva