Skip to content

[ComboBox] Popover-open refocus re-selects the whole value mid-typing, causing fast/programmatic input to be overwritten #14097

Description

@chriskari

Bug Description

When typing into a ui5-combobox, opening the suggestions popover triggers a programmatic refocus of the inner input, which runs the "select entire value" logic intended for a fresh user focus. If a keystroke arrives during the asynchronous popover-open window, it lands on a fully-selected input and overwrites the value typed so far.

Concretely, typing default character-by-character can end up as fault: after de, type-ahead correctly completes to default and selects only the suffix fault; then the popover finishes opening, focus is handed back to the input, the selection expands to the whole default, and the next keystroke replaces everything.

This is a timing/edge race — it predominantly affects fast or programmatic typing (e2e tools such as Cypress, possibly IME/paste sequences). A human typing at normal speed rarely hits the window, so it surfaces as a rare, hard-to-reproduce flake.

Affected Component

ComboBox

Expected Behaviour

Selecting-all on focus is correct for a genuine user focus. But when the popover-open sequence programmatically returns focus to the input during active typing, the in-progress value should be preserved — the remaining keystrokes should advance/append, not overwrite a newly select-all'd value.

Isolated Example

No response

Steps to Reproduce

  1. Render a ui5-combobox with several items, one of them default.
  2. Focus the input and type default character-by-character at a fast cadence (~10ms/char, as e2e tooling does), so a matching character opens the suggestions popover.
  3. Intermittently: once the popover finishes opening, the input's selection expands from the type-ahead suffix to the entire value, and the still-queued characters overwrite it — the final value ends up truncated/garbled (e.g. fault), and the popover filters to nothing.

Log Output, Stack Trace or Screenshots

combobox-focus-bug.mp4

Priority

Medium

UI5 Web Components Version

Observed on 2.24.0. Verified still present on the current latest 2.27.2 (ComboBox.js: _focusin line 341, _afterOpenPopover lines 366–368 — behavior unchanged).

Browser

Chrome

Operating System

No response

Additional Context

The two behaviors involved are each intentional; the defect is their interaction:

  • _focusin selects the whole value (setSelectionRange(0, this.value.length)) — correct for a user-initiated focus.
  • _afterOpenPopover calls this.inner.focus() to return focus to the input after the popover opens — correct for keyboard flow.

The problem: the programmatic refocus in _afterOpenPopover fires _focusin, which cannot distinguish "user just focused the field" from "focus was bounced back during typing," so it select-all's mid-edit. Because the popover open is async, a keystroke can slip in after the select-all.

Suggested scoped fix (not a removal of either behavior): suppress the _focusin select-all when the focus is the programmatic return from _afterOpenPopover while typing is in progress (e.g. guard on an "actively typing" flag), or avoid resetting the selection on that specific refocus. This preserves the standard select-all-on-user-focus UX and the post-open focus handling.

Organization

SAP Kyma

Declaration

  • I’m not disclosing any internal or sensitive information.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions