diff --git a/src/app/update/command.rs b/src/app/update/command.rs index 5a2896ef9..fa0453b4f 100644 --- a/src/app/update/command.rs +++ b/src/app/update/command.rs @@ -635,7 +635,23 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task { self.tabs[i].layers.edit_buf = new_name.clone(); } self.sync_ribbon_layers(); - Task::none() + // With alphabetical ordering (#270) the new layer can land + // anywhere in a long list; scroll its row into view so the + // rename prompt is visible (#271). Offset is layout-independent + // (idx × fixed row height), so it holds even before the freshly + // added row is measured. + match new_idx { + Some(idx) => iced::widget::operation::scroll_to( + iced::advanced::widget::Id::new( + crate::ui::window::layers::LAYER_TABLE_SCROLL_ID, + ), + iced::widget::scrollable::AbsoluteOffset { + x: 0.0, + y: idx as f32 * crate::ui::ROW_H, + }, + ), + None => Task::none(), + } } pub(super) fn on_layer_delete(&mut self) -> Task { diff --git a/src/ui/window/layers.rs b/src/ui/window/layers.rs index 3044063dd..b64879366 100644 --- a/src/ui/window/layers.rs +++ b/src/ui/window/layers.rs @@ -43,6 +43,9 @@ const ICON_SZ: f32 = ROW_H * 0.62; // ≈16 px at ROW_H=26 const FONT_SZ: f32 = ROW_H * 0.42; // ≈11 px at ROW_H=26 /// Vertical padding for combo_box / text_input so their total height = ROW_H. const COMBO_PAD_V: f32 = (ROW_H - FONT_SZ * 1.3 - 2.0) / 2.0; +/// Widget id for the layer-table scrollable, so a freshly created layer can be +/// scrolled into view after it is added (#271). +pub const LAYER_TABLE_SCROLL_ID: &str = "layer-manager-table-scroll"; // ── Layer data ──────────────────────────────────────────────────────────── @@ -127,7 +130,10 @@ impl Default for LayerPanel { }]), lw_combo: combo_box::State::new(lw_options()), vp_cols: vec![], - sort_col: None, + // Default to alphabetical (Name) order in both the Layer Manager + // table and the ribbon's quick layer dropdown (#270). A header + // click still re-sorts by any other column. + sort_col: Some(LayerSortCol::Name), sort_asc: true, } } @@ -384,7 +390,9 @@ impl LayerPanel { } - let table = scrollable(rows_col).height(Fill); + let table = scrollable(rows_col) + .id(iced::advanced::widget::Id::new(LAYER_TABLE_SCROLL_ID)) + .height(Fill); // ── Full-window frame ───────────────────────────────────────────── container(column![toolbar, col_header, table].spacing(0))