NileshPatel17 / ng-multiselect-dropdown

Multiple Select Dropdown Component
https://nileshpatel17.github.io/ng-multiselect-dropdown/
327 stars 287 forks source link

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

Open ETLJ opened 1 month ago

ETLJ commented 1 month ago

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