diff --git a/crates/ui-shell/src/shell/recent_list.rs b/crates/ui-shell/src/shell/recent_list.rs index 99ad9a332..dff34efa7 100644 --- a/crates/ui-shell/src/shell/recent_list.rs +++ b/crates/ui-shell/src/shell/recent_list.rs @@ -7,6 +7,7 @@ use super::start::{ }; use super::words::ShellWords; use crate::buttons::Button; +use crate::display::{Shade, Text}; use crate::contract::{ ActivateOn, BodyCx, CollectionEvent, Gap, Props as _, Remember as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing, clicked, @@ -83,7 +84,15 @@ impl<'a> RecentList<'a> { let shown = Section::fixed(words.recent.clone()) .header_gap(Gap::Section) .command_scope(StartRecentCommands::SCOPE) - .show(ui, |ui, cx| recent_body(&page, ui, cx, &files, RecentView::List, &empty)); + .show(ui, |ui, cx| { + // A list on a page says it is empty in a muted line at the reading start under its heading, where its + // rows would begin; the start screen's empty state stays the centred notice of `recent_body`. + if files.is_empty() { + let _ = Text::new(empty.clone()).shade(Shade::Muted).show(ui); + } else { + recent_body(&page, ui, cx, &files, RecentView::List, &empty); + } + }); StartOutput { response: shown.output.response, actions: actions.into_inner() } } } diff --git a/crates/ui-shell/src/shell/start/stories.rs b/crates/ui-shell/src/shell/start/stories.rs index 8a7f13a34..63907d8b9 100644 --- a/crates/ui-shell/src/shell/start/stories.rs +++ b/crates/ui-shell/src/shell/start/stories.rs @@ -159,6 +159,12 @@ fn recent_list(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { RecentList::new(&files).now(Some(NOW)).empty("No recent files").show(ui).into() } +/// No recent files: the muted line under the heading, at the reading start. +#[story(RecentList<'static>, covers = [], drive = Drive::Never)] +fn recent_list_empty(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + RecentList::new(&[]).empty("Documents you open will show up here.").show(ui).into() +} + #[story(StartScreen<'static>, covers = [], drive = Drive::Never)] fn start_screen_with_links(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let links = [ diff --git a/crates/ui-shell/tests/it/shell/start.rs b/crates/ui-shell/tests/it/shell/start.rs index a14136e3d..dfdc880a1 100644 --- a/crates/ui-shell/tests/it/shell/start.rs +++ b/crates/ui-shell/tests/it/shell/start.rs @@ -162,3 +162,18 @@ fn the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal() { assert!(fixture.by_label("Remove from Recent").is_some(), "a right click on a recent file opens its menu"); assert_eq!(fixture.by_label("Show in Folder").is_some(), craft_platform::open::CAN_REVEAL); } + +/// An empty recent list on a page says so in a line at the reading start under its heading, where its rows would +/// begin, not in the start screen's centred empty state (a File page's Open list). +#[trial] +fn an_empty_recent_list_says_so_at_the_reading_start() { + let files: Vec = Vec::new(); + let mut fixture = Fixture::new(move |ui| { + let _ = RecentList::new(&files).empty("Nothing opened yet").show(ui); + }); + fixture.room(egui::Vec2::new(700.0, 500.0)); + fixture.settle(); + let line = fixture.by_label("Nothing opened yet").expect("the empty line shows"); + assert!(line.rect.left() < 60.0, "the line starts at the list's start edge: {:?}", line.rect); + assert!(line.rect.width() < 300.0, "the line is as wide as its text: {:?}", line.rect); +}