Skip to content

Commit

Permalink
Fix panic when there are no glyph in the cluster found when hit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Jan 31, 2025
1 parent 5724bb6 commit c155774
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/blitz-dom/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,10 @@ impl Node {
let layout = &element_data.inline_layout_data.as_ref().unwrap().layout;
let scale = layout.scale();

Cluster::from_point(layout, x * scale, y * scale).map(|(cluster, _)| {
let style_index = cluster.glyphs().next().unwrap().style_index();
Cluster::from_point(layout, x * scale, y * scale).and_then(|(cluster, _)| {
let style_index = cluster.glyphs().next()?.style_index();
let node_id = layout.styles()[style_index].brush.id;
HitResult { node_id, x, y }
Some(HitResult { node_id, x, y })
})
} else {
None
Expand Down

0 comments on commit c155774

Please sign in to comment.