From f172ba2f2e06a604ebccccf00e4f226e45e1a586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 22 Apr 2024 14:52:52 +0200 Subject: [PATCH] focus method for menu-item --- packages/uui-menu-item/lib/uui-menu-item.element.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/uui-menu-item/lib/uui-menu-item.element.ts b/packages/uui-menu-item/lib/uui-menu-item.element.ts index 4eff7c485..b9694ff23 100644 --- a/packages/uui-menu-item/lib/uui-menu-item.element.ts +++ b/packages/uui-menu-item/lib/uui-menu-item.element.ts @@ -113,6 +113,15 @@ export class UUIMenuItemElement extends SelectOnlyMixin( demandCustomElement(this, 'uui-loader-bar'); } + async focus() { + await this.updateComplete; + this.shadowRoot + ?.querySelector< + HTMLButtonElement | HTMLAnchorElement | HTMLSpanElement + >('#label-button') + ?.focus?.(); + } + private _labelButtonChanged = (label?: Element | undefined) => { this.selectableTarget = label || this; };