From 31bda8a4fbd87a801db0f840ae86a58c4c9c1f68 Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 20 Nov 2026 13:57:58 +0000 Subject: [PATCH] craft-ui: a root shown at a rect that is not a number registers its egui widget at no place The root's widget takes its whole rect since f43fb4e2c2, so a NaN rect reached egui's create_widget, which asserts on it (value_drag's degenerate-rect trial). Before, the intersection with the clip hid it. --- crates/ui-contract/src/runtime/egui/response.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/ui-contract/src/runtime/egui/response.rs b/crates/ui-contract/src/runtime/egui/response.rs index 58d89971f..d83ad5691 100644 --- a/crates/ui-contract/src/runtime/egui/response.rs +++ b/crates/ui-contract/src/runtime/egui/response.rs @@ -31,10 +31,12 @@ pub(crate) fn to_egui(sense: Sense) -> egui::Sense { mapped } -/// A root's egui widget over `rect`, clipped by the caller. egui gives a widget of a disabled `Ui` no focus stop and -/// drops the focus it holds; the sense the pipeline passes decides whether the root is a stop (a disabled control with -/// a reason is), so the stop and the focus are kept here. +/// A root's egui widget over `rect`; egui clips its interact rect. egui gives a widget of a disabled `Ui` no focus stop +/// and drops the focus it holds; the sense the pipeline passes decides whether the root is a stop (a disabled control +/// with a reason is), so the stop and the focus are kept here. A rect that is not a number is at no place +/// (`Rect::NOTHING`): egui takes no such rect, and nothing can hit it. pub(crate) fn widget(ui: &Ui, id: Id, rect: Rect, sense: Sense) -> Response { + let rect = if rect.any_nan() { Rect::NOTHING } else { rect }; let ctx = ui.ctx(); let held = ctx.memory(|memory| memory.has_focus(id)); let response = ui.interact(rect, id, to_egui(sense));