Skip to content

Add accessible Ajax user combobox over the preload cap. - #2011

Open
shadyvb wants to merge 1 commit into
ticket/XWPENG-55-replace-select2from
ticket/XWPENG-55-user-picker
Open

Add accessible Ajax user combobox over the preload cap.#2011
shadyvb wants to merge 1 commit into
ticket/XWPENG-55-replace-select2from
ticket/XWPENG-55-user-picker

Conversation

@shadyvb

@shadyvb shadyvb commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Fixes XWPENG-55.

User pickers (records filter, settings exclude rules, alert author trigger) now share one decision point, Admin::get_preload_users_max() (wp_stream_preload_users_max filter, default 50):

  • Under the cap: the native <select> from Replace remaining Select2 and jquery-timeago uses with native equivalents. #2010.
  • Over the cap: an accessible combobox (src/js/utils/user-combobox.js) searching the existing wp_stream_filters endpoint. The hidden input is the only submitted value; blur and form-submit restore the last committed selection so a half-typed query cannot win a race against Filter/Save. Roles render as a group inside the listbox, filtered client-side alongside Ajax user results.

A stateless User_Picker collaborator owns option building and search; DB shrinks back to the stream-record store. Alert author trigger now stores any user id, seeds the saved author on quick edit, and no longer falsy-drops WP-CLI (0).

Stacked on #2010.

Test plan

  • Sites under the preload cap still show a native user <select>.
  • Sites over the cap show the combobox; search, select, and clear work.
  • A half-typed query is discarded on blur and on Filter/Save.
  • Keyboard + ARIA (listbox, active descendant, announcements) work.
  • Alert author trigger fires only for the chosen author, including WP-CLI.
  • Quick-edit keeps the saved author; exclude rules still round-trip role and user values.

… cap (XWPENG-55)

User pickers (records filter, settings exclude rules, alert author
trigger) now share one decision point, Admin::get_preload_users_max()
(new wp_stream_preload_users_max filter, default 50):

- Under the cap: the native <select> from the previous commit.
- Over the cap: an accessible combobox (src/js/utils/user-combobox.js)
  searching the existing wp_stream_filters endpoint. The hidden input is
  the only submitted value; blur and form-submit restore the last
  committed selection so a half-typed query can never win a race against
  Filter/Save. Roles render as a group inside the listbox
  (data-role-options), filtered client-side alongside Ajax user results,
  keeping one control in both modes like the previous Select2 dropdown.
  Stored values (role slug or user id, including 0 for WP-CLI) keep
  working unchanged.

Supporting changes:

- Extract a stateless User_Picker collaborator (classes/class-user-picker.php)
  and register it on Plugin; DB shrinks back to the stream-record store
  and Alert_Trigger_Author, Settings_Renderer, Admin_Ajax, and
  Alerts_List no longer depend on it.
- Alert author trigger: save_fields stores any user id (membership checks
  are impossible when options are not server-rendered); quick edit seeds
  the saved author from hidden row inputs, fixing the long-standing loss
  of the value on inline save; the numeric string '0' (WP-CLI) is no
  longer falsy-dropped in get_display_value() and check_record(), so
  WP-CLI alerts display and match correctly.
- Type Alert::$alert_meta as array, correcting the long-wrong @var int
  docblock; alert_meta is always an array in practice.
- Fix a swapped ($form, $picker) argument order in the exclude-rule
  renderer's row loop that the unit suite caught before commit.

Tests: User_Picker_Test (modes, labels, search, default-cap canary),
Log role-exclusion coverage, alert trigger mode/save/display/matching
units, ajax nonce rejection, renderer dual-mode markup; e2e suites for
the combobox (search/select/clear, race guard, keyboard + aria, wp.a11y
announcements, screen options, role/user round trips), alert author
trigger end-to-end (fires only for the trigger author, WP-CLI title,
quick edit), functional exclude rules, WP-CLI picker labels, multi-IP
round trip.

Signed-off-by: Shadi Sharaf <shady@sharaf.me>
@shadyvb
shadyvb added this pull request to stack #1987 September 10, 2026 13:58
@shadyvb shadyvb changed the title ticket/XWPENG 55 user picker Add accessible Ajax user combobox over the preload cap. Sep 10, 2026
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