Repository navigation
Hide empty option Add controls - #293
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
Hiding the Add button takes the reader's focus with it. aria-disabled kept the control focusable, so a keyboard add left the reader standing on it; visibility: hidden makes it unfocusable, and Chromium drops focus to <body> — the next Tab restarts from the top of the document.
I ran it both ways on DECISION_PAGE: fill the field, Tab to Add, Enter, round_trip. On cd5025f the active element afterwards is BUTTON:Add option; on this branch it is BODY. The same happens whenever the draft empties while the button holds focus, including a clear mirrored in from another tab through watchDraft.
The inline suggestion returns the reader to the field, which is also where they'd want to be to add another option. It needs focused added to the widget-api.js import list — outside the diff, so not suggestable inline. With both edits tests/test_render_options_addition.py still passes, and the probe reports INPUT:Another option.
Nothing else came up: clippedControls skips absolutely-positioned controls and coveredWords skips visibility: hidden text, so neither render gate changes here, and test_render_options{,_addition,_settled}.py, test_render_aim.py, and test_render_drafts.py are otherwise green on the merged tree.
Happy to push the fix (widget edit plus a focus assertion in the existing test) if you'd like.
Empty free-form option rows currently show a disabled Add button before the reader has typed anything. Hide that control until the draft contains text, while preserving its reserved space so typing does not reflow the field.
The active button keeps Leaf's shared ordinary-action styling. If the field empties while Add has focus, the field takes focus before the button hides. Browser coverage checks the empty and active states, alignment, keyboard submission and focus, minimum target size, and the shared button face.