From 8f999d4a0db80658664437e38bb51f2eaee6fe2d Mon Sep 17 00:00:00 2001 From: Elliott Marquez Date: Tue, 17 Oct 2023 15:38:47 -0700 Subject: [PATCH] fix(textfield): calling focus on textfield with a leading icon focuses the input PiperOrigin-RevId: 574285365 --- textfield/internal/text-field.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/textfield/internal/text-field.ts b/textfield/internal/text-field.ts index 5cb8b60b29..08c8c03ea2 100644 --- a/textfield/internal/text-field.ts +++ b/textfield/internal/text-field.ts @@ -779,4 +779,10 @@ export abstract class TextField extends LitElement { formStateRestoreCallback(state: string) { this.value = state; } + + override focus() { + // Required for the case that the user slots a focusable element into the + // leading icon slot such as an iconbutton due to how delegatesFocus works. + this.getInputOrTextarea().focus(); + } }