fix: wrap scrollbar in id_container so it resets on page change

This commit is contained in:
Ashley Wulber 2024-05-30 17:19:53 -04:00 committed by Michael Murphy
parent 4ceac69f09
commit a48e0797d4
2 changed files with 31 additions and 24 deletions

View file

@ -15,7 +15,6 @@ use crate::pages::{self, display, power, sound, system, time};
use crate::subscription::desktop_files;
use crate::widget::{page_title, search_header};
use crate::PageCommands;
use cosmic::app::command::message;
use cosmic::app::DbusActivationMessage;
use cosmic::iced::futures::SinkExt;
use cosmic::iced::Subscription;
@ -28,7 +27,9 @@ use cosmic::{
window, Length,
},
prelude::*,
widget::{column, container, icon, nav_bar, scrollable, segmented_button, settings},
widget::{
column, container, icon, id_container, nav_bar, scrollable, segmented_button, settings,
},
Element,
};
use cosmic_panel_config::CosmicPanelConfig;
@ -74,6 +75,11 @@ impl SettingsApp {
PageCommands::Workspaces => self.pages.page_id::<desktop::workspaces::Page>(),
}
}
fn id(&self) -> cosmic::iced_core::id::Id {
let cur_page_name = self.pages.info[self.active_page].id.as_ref();
cosmic::iced_core::id::Id::new(cur_page_name.to_owned())
}
}
#[derive(Clone, Debug)]
@ -496,6 +502,7 @@ impl cosmic::Application for SettingsApp {
.padding([theme.cosmic().space_xxs(), padding])
.width(Length::Fill)
.apply(scrollable)
.apply(|w| id_container(w, self.id()))
.into()
}