Skip to content

[web] Semantics on: mouse click on a button next to a focused TextField leaves EditableText focused but engine editing off (_isIntegerCoordinateNavigation + deferred safeBlur) #195763

Open

Description

@ichorid

Steps to reproduce

Flutter 3.47.0 stable (framework 4cf2416, engine 5f77625), web, --wasm (also seen with dart2js), semantics enabled (SemanticsBinding.instance.ensureSemantics()), Chrome desktop with a real mouse.

  1. A TextField is focused and the user is typing.
  2. Next to it is an IconButton that clears the field (for example a search ✕). It is visible only while the field has text.
  3. Click the ✕ with the mouse.
  4. Type again without clicking anything.

Expected results

The field keeps focus and the new keys are inserted, as on every other platform and with semantics off.

Actual results

Flutter still shows the field focused (focused underline, FocusNode.hasFocus == true, EditableText keeps the connection), but document.activeElement is <flutter-view>. The keys go nowhere. This happened in 10 of 10 runs in a Playwright trace with real Chrome pointer and keyboard input.

Analysis

  1. EnginePlatformDispatcher._addNavigationFocusHandler installs a capture-phase click listener. _isLikelyAssistiveTechnologyActivation → _isIntegerCoordinateNavigation treats a click whose clientX/clientY are whole numbers on a role="button" semantics node as an assistive-technology activation and calls focusWithoutScroll() on the button.
    Chrome reports whole-number clientX/clientY for ordinary mouse clicks at DPR 1, so every real mouse click on a button counts as an AT activation. A mousedown preventDefault() does not help, because the focus is moved by this click handler.
  2. The focus move blurs the semantics <input>. SemanticsTextEditingStrategy.disable() then calls viewManager.safeBlur(activeDomElement), which defers _transferFocusToViewRoot with Future(() => ...).
  3. The framework's next frame still reports the text field as focused, so editing is re-enabled on the input. Then the stale deferred safeBlur runs and moves the focus to the view root. Engine text editing is now off, but the framework still thinks the field is focused, and nothing reconnects it.

A related trigger with the same symptom: if a tooltip shows or hides while a semantics text field is focused (for example a different IconButton slides under the still pointer after the ✕ disappears), the route's semantics subtree is wrapped or unwrapped. That moves the focused <input> in the DOM, so it blurs, focus ends on <body>, and the keys are lost.

Pressing Backspace instead of clicking the ✕ never reproduces it (5 of 5 passed).

Workaround in our app

A capture-phase focusout listener for input/textarea[data-semantics-role="text-field"]. After Timer.run plus one frame, if the framework's primary focus is still that EditableText but document.activeElement is not its input, it calls unfocus() and, on the next frame, requestKeyboard() (with an explicit scheduleFrame()).

Suggestion

  • Do not use whole-number click coordinates as an AT signal. Desktop Chrome mouse clicks at DPR 1 always have whole-number coordinates. PointerEvent.pointerType, detail == 0, or the absence of a preceding pointerdown are more reliable signals.
  • Cancel or re-check the deferred safeBlur if the element is re-enabled or focused again before the timer runs.

Activity

  1. added
    a: text input
    engine
    a: accessibility
    platform-web
    team-web
    on Nov 2, 2026
  2. mbcorona commented on Nov 3, 2026

    @mbcorona
    Member

    Thanks @ichorid for the analysis.

    Confirmed from source (EnginePlatformDispatcher): a whole number coordinate click on a
    button or role=button is treated as assistive tech activation and focuses it, pulling
    focus off the field. The code comment even says real clicks are "often fractional".

    Related to #195289 and #195291.

  3. added
    P2
    triaged-web
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2a: accessibilitya: text inputengineplatform-webteam-webtriaged-web

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions