Skip to content

Commit

Permalink
feat(list-item): expose / override host focus
Browse files Browse the repository at this point in the history
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
  • Loading branch information
material-web-copybara authored and copybara-github committed Mar 14, 2023
1 parent 533ae6c commit d005d72
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion list/lib/listitem/list-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?.();
}
}

0 comments on commit d005d72

Please sign in to comment.