This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
select: focusOptionNode throws exception when parent container is removed from DOM during panel close #11885
Closed
Description
Bug
CodePen and steps to reproduce the issue:
Work in progress: https://stackblitz.com/edit/angularjs-material-11885?file=home%2Fhome.html
Detailed Reproduction Steps:
- The
md-select
needs to be in a section of the page that is hidden (or has its content hidden) by anng-if
. - Click on an element that causes the
ng-if
to show themd-select
. - Click on the
md-select
to open the options panel. - Click on an element that causes both
- the
ng-if
to hide themd-select
- the
md-select
to close its options panel
What is the expected behavior?
The md-select
is hidden and the options panel closes without any exceptions or issues.
What is the current behavior?
SelectProvider.focusOptionNode()
throws an exception when trying to call SelectMenuController.setActiveDescendant()
material/src/components/select/select.js
Line 1593 in a8954df
Because
menuController
is undefined
. This is passed in via SelectProvider.autoFocus()
:material/src/components/select/select.js
Lines 1616 to 1617 in a8954df
In addition to throwing the exception, there are reports that the whole app may freeze.
What is the use-case or motivation for changing an existing behavior?
Fix an edge case.
Which versions of AngularJS, Material, OS, and browsers are affected?
- AngularJS: 1.7.9
- AngularJS Material: 1.1.21-rc.0
- OS: macOS
- Browsers: Chrome 80
Is there anything else we should know? Stack Traces, Screenshots, etc.
Related to PR #11761.
Reported by @codymikol.