Skip to content

Commit

Permalink
fix: Check layout exists for collateral events (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 authored Jan 31, 2025
1 parent 88078ec commit 94cc2cf
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions crates/core/src/events/nodes_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl NodesState {
events: &[PlatformEvent],
) -> PotentialEvents {
let rdom = fdom.rdom();
let layout = fdom.layout();
let mut potential_collateral_events = PotentialEvents::default();

// Any mouse press event at all
Expand Down Expand Up @@ -83,20 +84,22 @@ impl NodesState {
if let Some(PlatformEventData::Mouse { cursor, button, .. }) =
recent_mouse_movement_event
{
let events = potential_collateral_events
.entry(EventName::MouseLeave)
.or_default();

// Emit a MouseLeave event as the cursor was moved outside the Node bounds
events.push(PotentialEvent {
node_id: *node_id,
layer: metadata.layer,
name: EventName::MouseLeave,
data: PlatformEventData::Mouse { cursor, button },
});

#[cfg(debug_assertions)]
tracing::info!("Unmarked as hovered {:?}", node_id);
if layout.get(*node_id).is_some() {
let events = potential_collateral_events
.entry(EventName::MouseLeave)
.or_default();

// Emit a MouseLeave event as the cursor was moved outside the Node bounds
events.push(PotentialEvent {
node_id: *node_id,
layer: metadata.layer,
name: EventName::MouseLeave,
data: PlatformEventData::Mouse { cursor, button },
});

#[cfg(debug_assertions)]
tracing::info!("Unmarked as hovered {:?}", node_id);
}

// Remove the node from the list of hovered nodes
return false;
Expand Down

0 comments on commit 94cc2cf

Please sign in to comment.