From b1716be7452acdc8297fabae53aa374fe9a166e1 Mon Sep 17 00:00:00 2001 From: sumibi-yakitori Date: Wed, 3 Nov 2021 03:46:42 +0900 Subject: [PATCH] egui_web: constrain the IME text agent to the canvas (#830) limit the position of the text agent to the height of the client area --- egui_web/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/egui_web/src/lib.rs b/egui_web/src/lib.rs index 8325de61a60..3298f978743 100644 --- a/egui_web/src/lib.rs +++ b/egui_web/src/lib.rs @@ -1242,7 +1242,10 @@ fn move_text_cursor(cursor: &Option, canvas_id: &str) -> Option<()> if is_mobile() == Some(false) { cursor.as_ref().and_then(|&egui::Pos2 { x, y }| { let canvas = canvas_element(canvas_id)?; - let y = y + (canvas.scroll_top() + canvas.offset_top()) as f32; + let y = (y + (canvas.scroll_top() + canvas.offset_top()) as f32).min( + canvas.client_height() as f32 + - text_agent().get_bounding_client_rect().height() as f32, + ); let x = x + (canvas.scroll_left() + canvas.offset_left()) as f32; // Canvas is translated 50% horizontally in html. let x = x - canvas.offset_width() as f32 / 2.0;