File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -252,9 +252,16 @@ pub fn ui_focus_system(
252252 // The mouse position relative to the node
253253 // (0., 0.) is the top-left corner, (1., 1.) is the bottom-right corner
254254 // Coordinates are relative to the entire node, not just the visible region.
255- let relative_cursor_position = camera_cursor_positions
256- . get ( & camera_entity)
257- . map ( |cursor_position| ( * cursor_position - node_rect. min ) / node_rect. size ( ) ) ;
255+ let relative_cursor_position =
256+ camera_cursor_positions
257+ . get ( & camera_entity)
258+ . and_then ( |cursor_position| {
259+ // ensure node size is non-zero in all dimensions, otherwise relative position will be
260+ // +/-inf. if the node is hidden, the visible rect min/max will also be -inf leading to
261+ // false positives for mouse_over (#12395)
262+ ( node_rect. size ( ) . cmpgt ( Vec2 :: ZERO ) . all ( ) )
263+ . then_some ( ( * cursor_position - node_rect. min ) / node_rect. size ( ) )
264+ } ) ;
258265
259266 // If the current cursor position is within the bounds of the node's visible area, consider it for
260267 // clicking
You can’t perform that action at this time.
0 commit comments