From 7e0eda8b5c06d46a7cf36bab49921438313e3ec4 Mon Sep 17 00:00:00 2001 From: Nikola Anachkov <87311182+NakataCode@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:19:06 +0300 Subject: [PATCH] fix(ui5-list): handle spacebar in inputs and textareas to avoid list activation (#9775) fix(Listitem): handle space in inputs and textareas to prevent list activation --- packages/main/src/ListItem.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/main/src/ListItem.ts b/packages/main/src/ListItem.ts index 8abc673e4c8e..71648982c854 100644 --- a/packages/main/src/ListItem.ts +++ b/packages/main/src/ListItem.ts @@ -254,6 +254,10 @@ abstract class ListItem extends ListItemBase { } async _onkeydown(e: KeyboardEvent) { + if ((isSpace(e) || isEnter(e)) && this._isTargetSelfFocusDomRef(e)) { + return; + } + super._onkeydown(e); const itemActive = this.type === ListItemType.Active, @@ -328,6 +332,13 @@ abstract class ListItem extends ListItemBase { } } + _isTargetSelfFocusDomRef(e: KeyboardEvent): boolean { + const target = e.target as HTMLElement, + focusDomRef = this.getFocusDomRef(); + + return target !== focusDomRef; + } + /** * Called when selection components in Single (ui5-radio-button) * and Multi (ui5-checkbox) selection modes are used.