From d005d7265e1d980d748c8d7fe3f7f6d9d848cbb2 Mon Sep 17 00:00:00 2001 From: Material Web Team Date: Tue, 14 Mar 2023 14:47:05 -0700 Subject: [PATCH] feat(list-item): expose / override host focus In select, we need to open the menu and focus the last-selected item. `delegatesFocus: true` was causing some flakiness, so I overrode the focus method. PiperOrigin-RevId: 516639115 --- list/lib/listitem/list-item.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/list/lib/listitem/list-item.ts b/list/lib/listitem/list-item.ts index b073db21b8..935e4a60a1 100644 --- a/list/lib/listitem/list-item.ts +++ b/list/lib/listitem/list-item.ts @@ -275,9 +275,13 @@ export class ListItemEl extends LitElement implements ListItem { // update or else it may cause the page to jump on first load. if (changed.has('active') && !this.isFirstUpdate && this.active && this.focusOnSelection) { - this.listItemRoot.focus(); + this.focus(); } this.isFirstUpdate = false; } + + override focus() { + this.listItemRoot?.focus?.(); + } }