commit | 4871110b25ee819fdcfe96118a6e3476ea9c85ef | [log] [tgz] |
---|---|---|
author | Alex Rudenko <[email protected]> | Wed Sep 29 08:24:10 2021 |
committer | Devtools-frontend LUCI CQ <devtools-frontend-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed Sep 29 11:16:10 2021 |
tree | e6fab3f2dc4990f4ddc1baa750d7a014283f7997 | |
parent | b6450566eed00c2fe3bcf1dce4533ee955156f6c [diff] [blame] |
Button: pass focus() to the inner button Without this it's not possible to focus the button programmatically. Bug: none Change-Id: Ib23bc03ec323da4d3a7ffa8d3371dcd3d3259ef7 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3192855 Reviewed-by: Jack Franklin <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
diff --git a/front_end/ui/components/buttons/Button.ts b/front_end/ui/components/buttons/Button.ts index 5214936..1bf7388 100644 --- a/front_end/ui/components/buttons/Button.ts +++ b/front_end/ui/components/buttons/Button.ts
@@ -30,7 +30,7 @@ export class Button extends HTMLElement { static readonly litTagName = LitHtml.literal`devtools-button`; - private readonly shadow = this.attachShadow({mode: 'open'}); + private readonly shadow = this.attachShadow({mode: 'open', delegatesFocus: true}); private readonly boundRender = this.render.bind(this); private readonly props: ButtonData = {}; @@ -59,6 +59,10 @@ ComponentHelpers.ScheduledRender.scheduleRender(this, this.boundRender); } + focus(): void { + this.shadow.querySelector('button')?.focus(); + } + connectedCallback(): void { this.shadow.adoptedStyleSheets = [buttonStyles]; ComponentHelpers.ScheduledRender.scheduleRender(this, this.boundRender);