Dialogs: a style options dialog keeps its tab through its first measuring run

With the current craft-libs, the first show of a properties dialog is a measuring run that can end before the dialog's body runs, and it then sets the first tab as the shown one. A tab picked before the first frame (Tabs in Paragraph Style Options) was lost, so the Tabs pane and its Clear All Tabs button were not shown. The style options dialogs now keep the tab that was shown before a measuring run.
This commit is contained in:
dotCooCoo committed 2026-11-29 02:37:49 -08:00
1 parent 452bf2013d
commit cfa2bbb878
2 files changed
+11 -1

No files matched your search

@@ -1126,7 +1126,15 @@ macro_rules! style_dialog {
}
fn show(&mut self, ui: &mut egui::Ui, stack: &craft::ui::dialog::DialogStack) -> Option<craft::ui::dialog::DialogResult<Self::Result>> {
craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack)
// A measuring run can end without running the dialog's body and then sets the first tab as the
// shown one. The dialog keeps the tab that was shown before that run.
let measuring = craft::ui::runtime::measure::active(ui.ctx());
let tab = self.inner.tab();
let shown = craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack);
if measuring && self.inner.tab() != tab {
let _ = craft::ui::dialog::StackDialog::set_json_field(&mut self.inner, ui.ctx(), "tab", serde_json::json!(tab));
}
shown
}
fn key(&self) -> Option<&str> {
@@ -574,6 +574,8 @@ fn clear_all_tabs_can_be_clicked_in_a_narrow_viewport() {
for _ in 0..5 {
frame(&mut app, vec![]);
}
// The dialog's first frames measure it before its body runs; the Tabs pane picked before them stays shown.
assert_eq!(fields(&app)["tab"], json!("tabs"), "the dialog left Tabs in its first frames at {width} points");
let out = frame(&mut app, vec![]);
let nodes = out.platform_output.accesskit_update.unwrap().nodes;
let clear = nodes