fix(ui): keep a typed layer or style name when the field loses focus

Renaming a layer or a style was only applied on Enter; clicking anywhere
else dropped the typed name. A click that moves focus off a field whose
text changed now commits it. New and Copy in the style managers open the
generated name for renaming, so a new style can be named right away.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-13 11:19:12 +03:00
1 parent 4639546472
commit f6503ad4d3
5 files changed
+93 -46

No files matched your search

+8 -1
View File
@@ -510,6 +510,13 @@ pub fn build_field_key_map(sections: &[PropSection]) -> HashMap<iced::widget::Id
/// the `WebFieldCopy` operation idiom: `focusable` fires for every focusable
/// widget, and we record the one that `is_focused()`.
pub fn sync_active_field_task() -> iced::Task<Message> {
focused_widget_task(Message::PropSyncActive)
}
/// Ask the widget tree which field holds keyboard focus.
pub fn focused_widget_task(
on_result: fn(Option<iced::advanced::widget::Id>) -> Message,
) -> iced::Task<Message> {
use iced::advanced::widget::operation::{Focusable, Outcome};
use iced::advanced::widget::{Id, Operation};
#[derive(Default)]
@@ -534,7 +541,7 @@ pub fn sync_active_field_task() -> iced::Task<Message> {
Outcome::Some(self.focused.clone())
}
}
iced::advanced::widget::operate(FocusedId::default()).map(Message::PropSyncActive)
iced::advanced::widget::operate(FocusedId::default()).map(on_result)
}
/// A translated choice label paired with the unchanged value stored in the
+8
View File
@@ -737,6 +737,13 @@ fn name_tip<'a>(name: &'a str) -> Element<'a, Message> {
.into()
}
/// The layer-name field while a rename is open; a click that moves focus
/// elsewhere commits the typed name.
pub fn rename_input_id() -> iced::widget::Id {
iced::widget::Id::new("layer-rename-input")
}
fn layer_row<'a>(
index: usize,
layer: &'a Layer,
@@ -803,6 +810,7 @@ fn layer_row<'a>(
// Name cell
let name_cell: Element<'_, Message> = if is_editing {
text_input("", edit_buf)
.id(rename_input_id())
.on_input(Message::LayerRenameEdit)
.on_submit(Message::LayerRenameCommit)
.size(FONT_SZ)