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

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

Open
ETLJ opened this issue Sep 4, 2024 · 0 comments
Open

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

ETLJ opened this issue Sep 4, 2024 · 0 comments

Comments

@ETLJ
Copy link

ETLJ commented Sep 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant