fix(layout): focus inline rename field on RENAME

Renaming a layout tab left keyboard focus on the command line, so typed
characters landed there until the user clicked the tab. Give the inline
rename text_input a stable id and return a focus task when the rename
starts so the user types straight into the field. (issue #86)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-12 14:18:31 +03:00
commit cd4d1c2535
2 changed files with 10 additions and 0 deletions

View file

@ -5103,6 +5103,11 @@ impl OpenCADStudio {
if name != "Model" {
self.layout_rename_state = Some((name.clone(), name));
self.layout_context_menu = None;
// Focus the inline field so the user types into it
// directly instead of the command line (issue #86).
return iced::widget::operation::focus(iced::widget::Id::new(
crate::ui::statusbar::LAYOUT_RENAME_INPUT_ID,
));
}
Task::none()
}

View file

@ -4,6 +4,10 @@ use iced::widget::tooltip::Position as TipPos;
use iced::widget::{button, container, mouse_area, row, text, text_input, tooltip, Row};
use iced::{Background, Border, Color, Element, Length, Theme};
/// Widget id of the inline layout-rename text input, so the rename can grab
/// keyboard focus the moment it opens (issue #86).
pub const LAYOUT_RENAME_INPUT_ID: &str = "layout_rename_input";
use crate::app::Message;
use crate::snap::Snapper;
use crate::ui::statusbar_config::{StatusBarConfig, StatusPill};
@ -574,6 +578,7 @@ fn space_tab<'a>(
if let Some(edit_val) = rename_edit {
// Inline rename text input with a cancel (✕) button.
let input = text_input("", edit_val)
.id(iced::widget::Id::new(LAYOUT_RENAME_INPUT_ID))
.on_input(Message::LayoutRenameEdit)
.on_submit(Message::LayoutRenameCommit)
.size(11)