Skip to content

Commit

Permalink
fix(select): ensure md-select selection logic uses fresh DOM references
Browse files Browse the repository at this point in the history
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
  • Loading branch information
material-web-copybara authored and copybara-github committed Jan 3, 2024
1 parent 68b078b commit 8942715
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion select/internal/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8942715

Please sign in to comment.