Skip to content

Conversation

@rustbasic
Copy link
Contributor

fix(web): prevent entire page from scrolling out of view in Chrome (WASM)

Problem
When using egui on the web, the browser (especially Chrome) occasionally triggers an unwanted page-level scroll. This happens because the hidden input element (text agent) used for IME/text input is sometimes positioned outside the visible bounds of the canvas, causing the browser to "scroll it into view."

Solution
I modified the move_to function in the web's text_agent to ensure the input element's position stays within the canvas height. By clamping the top property between 0.0 and canvas_height, we prevent the browser from incorrectly scrolling the entire page when the text agent moves.

  • Specific change: Applied clamp(0.0, canvas_height) to the clamped_y value before setting the CSS top property.

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Preview available at https://egui-pr-preview.github.io/pr/7888-patch162
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

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