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
- Navigate to EnterPR screen — weight input correctly receives focus (via
createRenderedNode)
- Type a weight and press Save
- Both fields are cleared (
tiValue changes from user input to "")
- Diff updates nodes in-place —
setStrProp PropText "" is sent, but no requestFocus
- 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
Problem
After saving a PR in prrrrrrrrr, focus jumps from the weight input to the notes input. The weight input has
tiAutoFocus = True, notes hastiAutoFocus = False.The root cause is in
Hatter.Render.diffRenderNode: when a TextInput is updated in-place (value cleared after save),tiAutoFocusis never checked or re-applied. Focus is only requested once duringcreateRenderedNode(initial node creation), but never again during subsequent diffs.Reproduction
createRenderedNode)tiValuechanges from user input to"")setStrProp PropText ""is sent, but norequestFocusCode
Render.hs:432-450— the TextInput in-place diff checks value, hint, inputType, onChange, and fontConfig, but skipstiAutoFocus:vs
Render.hs:199-200— initial creation does apply it:Secondary issue
EditText views are created without
imeOptions(ui_bridge_android.c:511). Android defaults toIME_ACTION_NEXTwhen there's a subsequent focusable EditText, so the soft keyboard shows "Next" which advances focus to the notes field even before pressing Save.Related
tiAutoFocusbut only works on creation)tiAutoFocussupport)