ng-multiselect-dropdown icon indicating copy to clipboard operation
ng-multiselect-dropdown copied to clipboard

Reactive FormControl#disable() method does not disable the dropdown

Open ETLJ opened this issue 5 months ago • 0 comments

Angular version: 18.1.0

ng-multiselect-dropdown version: 1.0.0

Description of issue: FormControl#disable() method does not disable the dropdown. Only the [disabled] attribute works, but disabling it with [disabled] causes a big warning message from angular:

  It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
  when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
  you. We recommend using this approach to avoid 'changed after checked' errors.

  Example:
  // Specify the `disabled` property at control creation time:
  form = new FormGroup({
    first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
    last: new FormControl('Drew', Validators.required)
  });

  // Controls can also be enabled/disabled after creation:
  form.get('first')?.enable();
  form.get('last')?.disable();

Steps to reproduce: Create the dropdown as a FormControl inside a FormGroup, then create a button that when clicked will call the dropdown FormControl's disable() method.

Expected result: The dropdown should be disabled.

Actual result: The dropdown remains enabled.

Demo: StackBlitz

ETLJ avatar Sep 04 '24 18:09 ETLJ