From 89427158b7a15265556db2f86423a9905760c696 Mon Sep 17 00:00:00 2001 From: Material Web Team Date: Wed, 3 Jan 2024 15:50:15 -0800 Subject: [PATCH] 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 --- select/internal/select.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/select/internal/select.ts b/select/internal/select.ts index c79271b8a..6a379082a 100644 --- a/select/internal/select.ts +++ b/select/internal/select.ts @@ -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; }