Skip to content

Fix(Web): prevent invisible IME agent from intercepting mouse clicks near cursor - #8273

Open
rustbasic wants to merge 3 commits into
emilk:mainfrom
rustbasic:p105
Open

Fix(Web): prevent invisible IME agent from intercepting mouse clicks near cursor#8273
rustbasic wants to merge 3 commits into
emilk:mainfrom
rustbasic:p105

Conversation

@rustbasic

@rustbasic rustbasic commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Fix(Web): prevent invisible IME agent from intercepting mouse clicks near cursor

Problem

In WASM/Web environments, egui provides IMEOutput to the browser to handle IME composition and mobile text input. The browser creates an invisible text agent (like a hidden <textarea>) based on the provided cursor_rect.

However, this hidden element often possesses a small physical hitbox (especially to the right of the cursor). This causes a bug where mouse clicks occurring slightly to the right of the text cursor are intercepted by the browser's hidden element and never reach the egui canvas, resulting in "dead zones" for user interaction.

Note that this symptom does not occur when the text cursor is placed between English characters, likely because the character spacing is too narrow for a dead zone to form. It only occurs when the cursor is positioned between non-English characters (such as Korean) or certain ASCII punctuation like a period (.).

Solution

This PR modifies the cursor_rect passed to IMEOutput to be a zero-width Rect (tiny_rect).

  • By setting the size to Vec2::ZERO, the browser's invisible agent no longer has a clickable area, ensuring all pointer events are correctly delivered to the egui canvas.
  • The left_bottom position is preserved, so IME candidate windows (like Hanja or Emoji pickers) still appear at the correct coordinate relative to the cursor.

Impact

  • Fixed: Clicking near/on the text cursor in TextEdit (WASM) is now 100% reliable.
  • No Regression: IME functionality remains intact as the positional anchor is unchanged.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

Preview available at https://egui-pr-preview.github.io/pr/8273-p105
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

Changed from `left_top()` to `left_bottom()` to change the scroll reference point.
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.

[WASM] Mouse click events blocked near text cursor (Dead zone caused by hidden browser elements)

1 participant