Skip to content

feat: let a host form field label and describe Flicker.select/1 - #16

Merged
C-Sinclair merged 1 commit into
mainfrom
feat/combobox-field-aria
Nov 10, 2026
Merged

C-Sinclair merged 1 commit into
mainfrom
feat/combobox-field-aria

Conversation

@C-Sinclair

Copy link
Copy Markdown
Collaborator

A host app that renders Flicker.select/1 inside its own form field needs to name and describe the combobox input itself. This PR adds three attrs to Flicker.select/1 and fixes searches for text that arrives without a keystroke.

  • aria_labelledby (string, default nil) points the input's aria-labelledby at a host element. When set, combobox_input/1 skips Flicker's visually-hidden <label>, so screen readers stop reading the name twice. The listbox's aria-labelledby uses the same id.
  • aria_describedby (string of ids, default nil) is appended after Flicker's own hint ids from describedby/4 on the input's aria-describedby.
  • aria_invalid (boolean, default false) renders aria-invalid="true" on the input only when true.
  • The .Nav hook's attachCursorReporting now counts keys held on the input. An input event with no key held pushes "query" with the value and cursor. Context-menu paste, drag and drop, and autofill take this path. Typing and Ctrl/Cmd+V hold a key, so they still go through phx-keyup and its debounce and are not pushed twice. The server's handle_event("query", ...) already ignores a repeat with unchanged text and cursor.
  • Flicker.palette/1 and Flicker.search/1 render their own inputs and do not call combobox_input/1, so they are unchanged.
<label id="user_locale_label" for="user_locale_picker-input">Language</label>
<Flicker.select
  id="user_locale_picker"
  field={@field}
  source={...}
  aria_labelledby="user_locale_label"
  aria_describedby="user_locale-help user_locale-error"
  aria_invalid={@field.errors != []}
/>

The new Flicker.SelectFieldAriaTest renders each attr and checks the server runs a search for a keyless "query" push. The hook's input listener and key counting are JavaScript, which ExUnit cannot run. That part needs a browser check.

CHANGELOG.md has no entry here because git_ops writes it from the commit at release.

Add aria_labelledby, aria_describedby and aria_invalid to Flicker.select/1.
The colocated .Nav hook now pushes "query" for text that arrives with no
key held, such as a context-menu paste, drag and drop, or autofill.
@C-Sinclair
C-Sinclair force-pushed the feat/combobox-field-aria branch from e650c24 to f1d1168 Compare November 10, 2026 15:45
@C-Sinclair
C-Sinclair marked this pull request as ready for review November 10, 2026 16:00
@C-Sinclair
C-Sinclair merged commit f37ff84 into main Nov 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant