Skip to content

Implement support for selection events - #5570

Merged
jkelleyrtp merged 3 commits into
DioxusLabs:mainfrom
ealmloff:selection
May 19, 2026
Merged

jkelleyrtp merged 3 commits into
DioxusLabs:mainfrom
ealmloff:selection

Conversation

@ealmloff

@ealmloff ealmloff commented May 19, 2026 •

Copy link
Copy Markdown
Member

The select event currently expose no event data. This PR adds selection data from the associated input/textarea element if it is associated with one

This makes it possible to implement components like DioxusLabs/dioxus-components#255 in dioxus without eval

@ealmloff ealmloff added enhancement New feature or request html Related to the html crate labels May 19, 2026
@ealmloff
ealmloff marked this pull request as ready for review May 19, 2026 20:04
@ealmloff
ealmloff requested a review from a team as a code owner May 19, 2026 20:04
@jkelleyrtp
jkelleyrtp merged commit 01afa54 into DioxusLabs:main May 19, 2026
36 of 37 checks passed
SilentVoid13 pushed a commit to SilentVoid13/dioxus that referenced this pull request May 21, 2026
MentalGear pushed a commit to MentalGear/dioxus-components that referenced this pull request Sep 14, 2026
Adds the Input OTP one-time-passcode entry control (row 64,
docs/component-backlog.md): primitives/src/input_otp.rs
(InputOtp/InputOtpGroup/InputOtpSlot/InputOtpSeparator) plus its themed
wrapper at preview/src/components/input_otp/, registered in
preview/src/components/mod.rs and the root component.json.

Original composition, not a port. It builds on the *shape* of
Checkbox's BubbleInput pattern (primitives/src/checkbox.rs) -- one
real, accessible, form-participating <input> kept in sync with a
styled visual overlay -- but not BubbleInput itself: Checkbox's
visible control is a <button>, which is not a submittable element, so
it needs a second hidden native input purely for form participation.
Input OTP's real <input type="text"> is simultaneously the
interactive control (keystrokes, paste, caret) and the
form-submittable one, so no second hidden input is needed here. The
new DOM-caret-to-Rust-signal bridge (use_caret_sync, local to
input_otp.rs) reuses the eval-listener-then-stream-back *shape* of
crate::use_form_reset_listener/use_dialog_close_sync (lib.rs), needed
because dioxus-html's SelectionEvent/SelectionData carries no
cross-platform-readable selection range.

No APG pattern exists for "OTP input" (verified against APG's pattern
index and shadcn/ui's own docs, which describe InputOTP as a styled
plain <input>), so this follows WCAG's generic text-input requirements
instead: the real, focusable, labelled <input> is the accessible
source of truth; InputOtpSlot/InputOtpGroup/InputOtpSeparator render
inside an aria-hidden presentational layer.

Two references were read, never vendored, per docs/lifting-from-forks.md
§1: upstream Dioxus PR DioxusLabs#255 (ealmloff, draft, 21 commits) -- re-checked
this session and still draft/blocked (last activity 2026-05-19, still
waiting on DioxusLabs/dioxus#5570 for select-event-handler
integration); and dignifiedquire/rust-ui's input_otp.rs, shape/edge-case
reference only. Nothing lifted, so no provenance header or ledger entry.

Verification actually run this session:
- cargo check --workspace: clean.
- cargo fmt --check: clean.
- cargo clippy --workspace --tests --examples -- -D warnings: adds no
  new warnings. The bare command still fails on the three pre-existing,
  unrelated issues noted in this session's task scope (menu_sub.rs doc
  lint, field.rs dead-code FieldOrientation::Responsive, main.rs
  function-pointer comparison in the #[component] macro); reproduced
  identically with -A flags for those three lints, which then passes
  clean across the whole workspace -- confirming this diff introduces
  nothing new.
- scripts/check-preview-composition.sh, check-cfg-axis.sh,
  check-dx-class-prefix.sh, check-css-literals.sh: all OK (class-prefix
  script's only output is the pre-existing top_layer warning).
- playwright/input_otp.spec.ts, real execution: `npx playwright test
  --project=chromium` against a local `dx run --web --release` build
  (chromium-1223, matching this sandbox's pinned Playwright/opt/pw-browsers
  revision) -- 5 passed, 0 failed (typing/value-mirroring smoke test,
  paste-fills-all-slots, Backspace/Delete/ArrowLeft/ArrowRight
  active-slot movement, disabled-blocks-input, one axe scan).

Also updates docs/component-backlog.md's Input OTP row (marks it
landed, records what was built/reused/verified) and docs/backlog.md's
"Fresh-session order" item 6 (Input OTP landed; Command/Drawer/
Navigation Menu/Resizable remain next in that wave).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TnGrdUKiZR7huWJbaxtujf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request html Related to the html crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants