fix(select): ensure md-select selection logic uses fresh DOM references

Previously selectItem would work with cached references to select-option elements which could become stale causing the deactivation logic to fail. This cl just ensures that selectItem always re-fetches the nodes to avoid the issue.

PiperOrigin-RevId: 595524158
This commit is contained in:
Material Web Team 2024-01-03 15:50:15 -08:00 committed by Copybara-Service
parent 68b078b4e1
commit 89427158b7

View File

@ -725,7 +725,8 @@ export abstract class Select extends selectBaseClass {
* @return Whether the last selected option has changed.
*/
private selectItem(item: SelectOption) {
this.lastSelectedOptionRecords.forEach(([option]) => {
const selectedOptions = this.getSelectedOptions() ?? [];
selectedOptions.forEach(([option]) => {
if (item !== option) {
option.selected = false;
}