Skip to content

fix(dioxus): synthesize auxclick + position-guard contextmenu in Actions#495

Merged
goosewobbler merged 2 commits into
mainfrom
fix/dioxus-actions-auxclick-contextmenu
Jun 30, 2026
Merged

fix(dioxus): synthesize auxclick + position-guard contextmenu in Actions#495
goosewobbler merged 2 commits into
mainfrom
fix/dioxus-actions-auxclick-contextmenu

Conversation

@goosewobbler

Copy link
Copy Markdown
Contributor

Closes #494 — the two DOM-event-completeness gaps deferred from #488's Actions handler. Both are in packages/dioxus-embedded-driver/src/server/handlers/actions.rs.

1. auxclick for non-primary clicks

Per the UI Events spec, a same-spot press+release of a non-primary button fires auxclick (the non-primary counterpart of click). Before this PR a middle-button click synthesized no high-level event and a right-button click fired only contextmenu. Now:

button events on same-spot release
0 (primary) click (+ dblclick on the second) — unchanged
1 (middle) auxclick
2 (right) auxclick + contextmenu

2. contextmenu position guard (right-button drag)

The primary path only fired click when press and release shared a position; the right button fired contextmenu unconditionally, so a right-button drag (press A → move → release B) still popped a context menu. Now every activation is position-guarded.

Implementation

Generalized the primary-only primary_down_pos: Option<…> to a per-button down_pos: HashMap<u32, (i32, i32)>, so the same-position guard and the per-button event set apply uniformly across all buttons (and pointerCancel drops the canceled source's entries). The event set lives in a pure activation_events(button) helper; dblclick stays primary-only (it needs cross-gesture state).

Tests

  • activation_events_per_button — primary→click, middle→auxclick, right→auxclick+contextmenu, other-non-primary→auxclick.
  • auxclick builder assertion alongside the existing click/contextmenu/dblclick ones.
  • cargo test --lib: 24 passed. cargo clippy --all-targets: clean.

Out of scope

Native engine-only behaviors for trusted input (real OS context menu, native selection) — synthesized DOM events can't reproduce those, per #488's documented limitations.

🤖 Generated with Claude Code

Closes #494. Two DOM-event-completeness gaps in the embedded driver's W3C
Actions handler:

- Non-primary clicks now synthesize `auxclick` (the spec's non-primary
  counterpart to `click`): middle-button → `auxclick`, right-button →
  `auxclick` + `contextmenu`. Previously a middle click emitted no
  high-level event and right emitted only `contextmenu`.
- `contextmenu` (and every activation) is now position-guarded: a button's
  press and release must land on the same spot, so a right-button drag no
  longer pops a contextmenu. Generalized the primary-only `primary_down_pos`
  tracking to a per-button `down_pos` map driving the same-position guard
  uniformly; `dblclick` stays primary-only.

The event set per button lives in a pure `activation_events()` helper with
unit coverage; added an `auxclick` builder assertion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Standing release PR: #456 · 9 packages queued · open 158h 36m · ✅ ready to merge

Release Preview — 12 packages

Note: Labels on this PR are advisory in standing-pr mode. Bumps come from conventional commits in the standing PR; override by editing labels on the standing PR itself. Add release:immediate to bypass the standing PR and release this PR directly.

These changes will be added to the release PR (#456) when merged:

Changelog

@wdio/dioxus-bridge 1.0.0-next.3 → 1.0.1

Changed

  • Update version to 1.0.1
@wdio/dioxus-service 1.0.0-next.3 → 1.0.1

Changed

  • Update version to 1.0.1
wdio-dioxus-driver 1.0.0-next.3 → 1.0.1

Changed

  • Update version to 1.0.1
wdio-dioxus-embedded-driver 1.0.0-next.3 → 1.0.1

Changed

  • correct down_pos comment to describe all-button tracking (dioxus)

Fixed

@wdio/tauri-service 1.2.0 → 1.2.1

Changed

  • Update version to 1.2.1
@wdio/flutter-service 1.0.0-next.1 → 1.0.1

Changed

  • Update version to 1.0.1
wdio_flutter N/A → 1.0.1

Changed

  • Update version to 1.0.1
@wdio/electron-service 10.1.0 → 10.1.1

Changed

  • Update version to 10.1.1
@wdio/native-core 1.0.0 → 1.0.1

Changed

  • Update version to 1.0.1
@wdio/native-mobile-core 1.0.0 → 1.0.1

Changed

  • Update version to 1.0.1
@wdio/native-spy 1.1.0 → 1.1.1

Changed

  • Update version to 1.1.1
@wdio/native-utils 2.4.0 → 2.4.1

Changed

  • Update version to 2.4.1
@wdio/react-native-service 1.0.0-next.0 → 1.0.1

Changed

  • Update version to 1.0.1

After merge — predicted release

No version escalation — this PR's changes will be included in the queued release without affecting the projected versions.

Package Standing PR This PR After merge
@wdio/electron-service 10.2.0 10.1.1 10.2.0
@wdio/flutter-service 1.0.1 1.0.1 1.0.1
@wdio/native-core 1.1.0 1.0.1 1.1.0
@wdio/native-mobile-core 1.1.0 1.0.1 1.1.0
@wdio/native-spy 1.2.0 1.1.1 1.2.0
@wdio/native-utils 2.5.0 2.4.1 2.5.0
@wdio/react-native-service 1.1.0 1.0.1 1.1.0
@wdio/tauri-service 1.2.1 1.2.1 1.2.1
wdio_flutter 1.0.1 1.0.1 1.0.1

Updated automatically by ReleaseKit

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fills two DOM-event gaps in the Actions handler: it synthesizes auxclick for non-primary button clicks (middle and right), and it applies the same press-position guard to contextmenu that primary clicks already had, preventing a right-button drag from popping a context menu. The primary_down_pos: Option<…> field is generalized to down_pos: HashMap<u32, (i32, i32)> and a new pure activation_events(button) helper encapsulates the per-button event set.

  • activation_events helper — pure match returning ["click"] for primary, ["auxclick"] for any non-primary, and ["auxclick", "contextmenu"] for the right button; ordering matches the UI Events spec.
  • Position-guarded contextmenudown_pos.remove(button) == Some(pos) now gates all activation events uniformly across buttons; right-button drags no longer produce a spurious context menu.
  • PointerCancel updated — removes per-button down_pos entries for the canceled source's buttons, consistent with how held_mask and pressed_buttons are cleared.

Confidence Score: 5/5

Safe to merge — well-scoped, spec-aligned change that generalizes an existing pattern without altering primary-button behavior.

The activation-event logic is isolated to the PointerUp arm, the activation_events helper is pure and exhaustively unit-tested, the position-guard now applies uniformly to all buttons, and PointerCancel correctly cleans up the new down_pos map. No existing behavior for the primary button is altered, and 24 tests pass cleanly.

No files require special attention.

Important Files Changed

Filename Overview
packages/dioxus-embedded-driver/src/server/handlers/actions.rs Adds activation_events(button) helper and replaces primary_down_pos: Option<…> with down_pos: HashMap<u32, (i32, i32)> to synthesize auxclick/contextmenu per spec and position-guard context menus; logic is correct and well-tested.

Reviews (2): Last reviewed commit: "docs(dioxus): correct down_pos comment t..." | Re-trigger Greptile

Comment thread packages/dioxus-embedded-driver/src/server/handlers/actions.rs Outdated
Greptile P2: the comment was carried over from the old primary-only
`primary_down_pos` and mis-described the generalized per-button `down_pos`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@goosewobbler goosewobbler merged commit a44a709 into main Jun 30, 2026
93 checks passed
@goosewobbler goosewobbler deleted the fix/dioxus-actions-auxclick-contextmenu branch June 30, 2026 02:38
@github-actions github-actions Bot mentioned this pull request Jun 30, 2026
12 tasks
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.

Dioxus actions: synthesize auxclick for non-primary clicks + guard contextmenu against right-button drag

1 participant