Fix shared element state across component instances

This commit is contained in:
2026-11-09 14:04:25 +07:00
parent f022f08947
commit 73f7dc31d4
20 changed files with 489 additions and 136 deletions
+1 -1
View File
@@ -1016,7 +1016,7 @@ fn render_pane(
move |_, _| {
tabs.iter()
.map(|tab| {
let mut entry = Tab::new(tab.title.clone());
let mut entry = Tab::new(tab.panel.clone(), tab.title.clone());
if let Some(role) = tab.icon {
entry = entry.icon(role);
}
+8
View File
@@ -255,6 +255,14 @@ impl RenderOnce for ResizeHandle {
return;
}
if event.pressed_button != Some(MouseButton::Left) {
drag.update(cx, |drag, cx| {
drag.dragging = false;
cx.notify();
});
return;
}
let delta = match axis {
Axis::Horizontal => event.position.x - last.x,
Axis::Vertical => event.position.y - last.y,
+22
View File
@@ -151,6 +151,28 @@ fn moves_without_a_drag_report_nothing() {
assert!(deltas.borrow().is_empty());
}
/// The button may be released outside the window, where no MouseUp is
/// delivered — the drag must end when a move reports no pressed button.
#[test]
fn releasing_outside_the_window_ends_the_drag() {
let (_cx, deltas, _resets, mut visual) = handle_window(Axis::Horizontal, false);
let start = handle_center(&mut visual);
visual.simulate_mouse_down(start, MouseButton::Left, Modifiers::default());
visual.simulate_event(MouseMoveEvent {
position: point(start.x + px(30.), start.y),
pressed_button: None,
modifiers: Modifiers::default(),
});
visual.simulate_event(MouseMoveEvent {
position: point(start.x + px(60.), start.y),
pressed_button: None,
modifiers: Modifiers::default(),
});
assert!(deltas.borrow().is_empty(), "the drag outlived its button");
}
#[test]
fn arrow_keys_move_the_seam_when_focused() {
let (_cx, deltas, _resets, mut visual) = handle_window(Axis::Horizontal, false);