Repository navigation
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
It is rather complicated to sum up the situation, here is my SO-Posting on the matter:
https://stackoverflow.com/questions/45420803/browseranimationsmodule-altering-behaviour-of-select-dropdowns
Basically, when I programmatically remove an option form a dropdown, I dont want the selection to change. In case the select-dropdown is pristine, removing an option will cause the select to display the first option as the selected one:
Here is the defective plunkr:
https://plnkr.co/edit/ayzM2HNtO6Hkkr8jkgVA?p=preview
Expected behavior
I dont think the selection of a pristine select should change, when an option is removed programmatically. Here is a working plunkr:
https://plnkr.co/edit/dPDpEQm14pWlFNfLe4nP?p=preview
Now the thin is, the only difference between defective and working plunkr is that in the working plunkr I have remove the BrowserAnimationsModule from the Module-Imports (at the bottom of the file, I did keep the ts-import )
This makes it seem that the BrowserAnimaitonsModule is somehow responsible for changing the behaviour of the select-dropdown.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Environment
Angular version: 4.3.2
Browser:
- [x ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ x] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: XX
- Platform:
Others:
Activity
matsko commentedon Oct 31, 2017
So to verify, the dropdown's selected value flips to
1when BrowserAnimationsModule is present (otherwise it stays selected as is) correct?tobias74 commentedon Nov 5, 2017
Correct, the value flips. Removing the BrowserAnimationsModule solves the issue. Using a third-party-select like the angular/material-select dos not show the issue.
YounesM commentedon Dec 21, 2017
The value doesn't flip as the model stays empty. It only displays an element as selected where none are. Here is another defective example : https://stackblitz.com/edit/angular-pjrg1p
A simple workaround is to add
animations: [ trigger('',[])]to your components.tobias74 commentedon Oct 30, 2018
I have made a stackblitz for this bug, since the original plunkr-exmaple does not load anymore:
https://stackblitz.com/edit/angular-animations-dropdown-bug
(Using angular 7.0.1)
FritzHerbers commentedon Mar 1, 2019
I am having a problem with BrowserAnimationsModule (by just loading it/not using it), ngx-formly and selects.
When options are loaded a second time and there is no model for a select, the first option is choosen.
See https://stackblitz.com/edit/angular-sg8rfv?file=src%2Fapp%2Fapp.module.ts with the steps to reproduce.
Since Jan 23, 2018 this issue is moved to the backlog, will it be checked again by occasion?
theodorejb commentedon Nov 8, 2019
I spent a lot of time debugging before I figured out that this issue was caused by the presence of
BrowserAnimationsModule. Here's a simple demo illustrating the bug in Angular 8: https://stackblitz.com/edit/angular-bam-select-bug?file=src%2Fapp%2Fapp.module.ts.Why does the animation module break select dropdowns like this? I started having this issue after adding an Angular Material component to my app, which depends on the animations module.
There are multiple Stack Overflow questions stemming from this bug:
theodorejb commentedon Nov 10, 2019
Using my StackBlitz example, I opened the Firefox dev tools and set a breakpoint on DOM mutation of the select element subtree, as well as a breakpoint in the select_control_value_accessor
writeValuemethod. Normally, the code to remove the submitted option element from the DOM runs before thewriteValuemethod. However, whenBrowserAnimationsModuleis present, the order is reversed, and the submitted option element isn't removed until afterwriteValueis called. This makes thewriteValuecall pointless, as subsequent modification of the option elements overrides the select element value.Is there a bug in
BrowserAnimationsModulethat causes the order of operations to change, or does it change the order intentionally? It certainly seems like a bug for the module to change behavior like that even when no animations are being used.theodorejb commentedon Nov 12, 2019
This is still an problem in the latest Angular 9 release candidate with Ivy enabled. Fortunately I found that my patch in pull request #23784 will fix this issue if it is merged.
xonuzofa commentedon Apr 28, 2020
Also here: Issue 35896
2 remaining items
kheos31 commentedon Feb 16, 2024
Hello everyone. As everybody, i'm sad to detect this issue again. Any news on the linked PR? We're currently faced to this problem and it's really annoying to have to try to predict in our externalized Angular libraries if an integration application will import BrowserAnimationModule or not..
tobias74 commentedon Dec 7, 2024
I have made a new Plunker for this: https://plnkr.co/edit/jI9GEvgQSTWNSTrf
Here is how you can trigger the issue: Just click on "Click Me". After clicking the button the dropdown will show the first item as being selected (even when explicitly setting the value to an empty string). This behaviour only exists as long as the BrowserAnimationsModule is imported.
In this Pluncker without the imported BrowserAnimationsModule everything works as expected: https://plnkr.co/edit/dLtdUfkgxm4iArx4
fix(forms): improve select performance and ensure that selected optio…
fix(forms): improve select performance
fix(forms): improve select performance
fix(forms): improve select performance
fix(forms): improve select performance
fix(forms): improve select performance (#61949)
angular-automatic-lock-bot commentedon Jul 11, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.