Skip to content

Commit

Permalink
fix(ui5-list): handle spacebar in inputs and textareas to avoid list …
Browse files Browse the repository at this point in the history
…activation (#9775)

fix(Listitem): handle space in inputs and textareas to prevent list activation
  • Loading branch information
NakataCode authored Oct 7, 2024
1 parent ed98977 commit 7e0eda8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/main/src/ListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 7e0eda8

Please sign in to comment.