Skip to content

TextInput autoFocus not re-applied during in-place diff #217

@jappeace-sloth

Description

@jappeace-sloth

Problem

After saving a PR in prrrrrrrrr, focus jumps from the weight input to the notes input. The weight input has tiAutoFocus = True, notes has tiAutoFocus = False.

The root cause is in Hatter.Render.diffRenderNode: when a TextInput is updated in-place (value cleared after save), tiAutoFocus is never checked or re-applied. Focus is only requested once during createRenderedNode (initial node creation), but never again during subsequent diffs.

Reproduction

  1. Navigate to EnterPR screen — weight input correctly receives focus (via createRenderedNode)
  2. Type a weight and press Save
  3. Both fields are cleared (tiValue changes from user input to "")
  4. Diff updates nodes in-place — setStrProp PropText "" is sent, but no requestFocus
  5. Focus drifts to the notes EditText instead of staying on / returning to weight

Code

Render.hs:432-450 — the TextInput in-place diff checks value, hint, inputType, onChange, and fontConfig, but skips tiAutoFocus:

diffRenderNode _ (Just (RenderedLeaf (TextInput oldConfig) nodeId)) newWidget@(TextInput newConfig) = do
  if tiValue oldConfig /= tiValue newConfig ...
  if tiHint oldConfig /= tiHint newConfig ...
  if tiInputType oldConfig /= tiInputType newConfig ...
  if onChangeId ... /= onChangeId ...
  if tiFontConfig oldConfig /= tiFontConfig newConfig ...
  -- tiAutoFocus is never checked here

vs Render.hs:199-200 — initial creation does apply it:

when (tiAutoFocus config) $
  Bridge.setNumProp nodeId Bridge.PropAutoFocus 1.0

Secondary issue

EditText views are created without imeOptions (ui_bridge_android.c:511). Android defaults to IME_ACTION_NEXT when there's a subsequent focusable EditText, so the soft keyboard shows "Next" which advances focus to the notes field even before pressing Save.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions