From 6d28cce719d9fd59d5e12b4c78ef47074a0b6d89 Mon Sep 17 00:00:00 2001 From: Floyd Wang Date: Wed, 23 Jul 2025 19:12:13 +0800 Subject: [PATCH] notification: Fix display issues caused by the `taffy` upgrade (#1084) --- crates/story/examples/dock.rs | 9 +++++---- crates/story/examples/tiles.rs | 2 +- crates/story/src/lib.rs | 2 +- crates/ui/src/notification.rs | 34 ++++++++++++---------------------- crates/ui/src/root.rs | 3 +++ 5 files changed, 22 insertions(+), 28 deletions(-) diff --git a/crates/story/examples/dock.rs b/crates/story/examples/dock.rs index 37896cd2..b484d4ef 100644 --- a/crates/story/examples/dock.rs +++ b/crates/story/examples/dock.rs @@ -11,9 +11,9 @@ use serde::Deserialize; use std::{sync::Arc, time::Duration}; use story::{ AccordionStory, AppState, AppTitleBar, Assets, ButtonStory, CalendarStory, DropdownStory, - FormStory, IconStory, ImageStory, InputStory, LabelStory, ListStory, ModalStory, Open, - PopoverStory, ProgressStory, ResizableStory, ScrollableStory, SidebarStory, StoryContainer, - SwitchStory, TableStory, TooltipStory, WebViewStory, + FormStory, IconStory, ImageStory, InputStory, LabelStory, ListStory, ModalStory, + NotificationStory, Open, PopoverStory, ProgressStory, ResizableStory, ScrollableStory, + SidebarStory, StoryContainer, SwitchStory, TableStory, TooltipStory, WebViewStory, }; #[derive(Action, Clone, PartialEq, Eq, Deserialize)] @@ -361,6 +361,7 @@ impl StoryWorkspace { Arc::new(StoryContainer::panel::(window, cx)), Arc::new(StoryContainer::panel::(window, cx)), Arc::new(StoryContainer::panel::(window, cx)), + Arc::new(StoryContainer::panel::(window, cx)), ], None, &dock_area, @@ -522,7 +523,7 @@ impl Render for StoryWorkspace { .child(self.dock_area.clone()) .children(drawer_layer) .children(modal_layer) - .child(div().absolute().top_8().children(notification_layer)) + .children(notification_layer) } } diff --git a/crates/story/examples/tiles.rs b/crates/story/examples/tiles.rs index 34987fee..d77f7d3e 100644 --- a/crates/story/examples/tiles.rs +++ b/crates/story/examples/tiles.rs @@ -412,7 +412,7 @@ impl Render for StoryTiles { .child(self.dock_area.clone()) .children(drawer_layer) .children(modal_layer) - .child(div().absolute().top_8().children(notification_layer)) + .children(notification_layer) } } diff --git a/crates/story/src/lib.rs b/crates/story/src/lib.rs index 666f2342..6416361d 100644 --- a/crates/story/src/lib.rs +++ b/crates/story/src/lib.rs @@ -245,7 +245,7 @@ impl Render for StoryRoot { ) .children(drawer_layer) .children(modal_layer) - .child(div().absolute().top_8().children(notification_layer)) + .children(notification_layer) } } diff --git a/crates/ui/src/notification.rs b/crates/ui/src/notification.rs index c587a3cf..9d36ef35 100644 --- a/crates/ui/src/notification.rs +++ b/crates/ui/src/notification.rs @@ -398,7 +398,7 @@ impl NotificationList { if let Err(err) = notification.update_in(cx, |note, window, cx| note.dismiss(window, cx)) { - println!("failed to auto hide notification: {:?}", err); + tracing::error!("failed to auto hide notification: {:?}", err); } }) .detach(); @@ -438,26 +438,16 @@ impl Render for NotificationList { let size = window.viewport_size(); let items = self.notifications.iter().rev().take(10).rev().cloned(); - div() - .absolute() - .flex() - .top_4() - .bottom_4() - .right_4() - .justify_end() - .child( - v_flex() - .id("notification-list") - .absolute() - .relative() - .right_0() - .h(size.height - px(8.)) - .on_hover(cx.listener(|view, hovered, _, cx| { - view.expanded = *hovered; - cx.notify() - })) - .gap_3() - .children(items), - ) + div().absolute().top_4().right_4().child( + v_flex() + .id("notification-list") + .h(size.height - px(8.)) + .on_hover(cx.listener(|view, hovered, _, cx| { + view.expanded = *hovered; + cx.notify() + })) + .gap_3() + .children(items), + ) } } diff --git a/crates/ui/src/root.rs b/crates/ui/src/root.rs index 71a07b1f..10a329d5 100644 --- a/crates/ui/src/root.rs +++ b/crates/ui/src/root.rs @@ -277,6 +277,9 @@ impl Root { Some( div() + .absolute() + .top_0() + .right_0() .when_some(mt, |this, offset| this.mt(offset)) .when_some(mr, |this, offset| this.mr(offset)) .child(root.read(cx).notification.clone()),