Keep the composer out of a dialog's field order

This commit is contained in:
Georg Bauer
2026-07-26 10:11:40 +02:00
parent a0c3a72f4e
commit 671724949f
2 changed files with 34 additions and 5 deletions

View File

@@ -62,6 +62,15 @@ impl App {
} }
} }
/// Whether a dialog covers the window. Focus moves through the whole widget
/// tree, so the layers below have to stay out of the dialog's field order.
pub(super) fn modal_open(&self) -> bool {
self.preferences_open
|| self.pending_project_path.is_some()
|| self.session_rename.is_some()
|| self.menu_session().is_some()
}
fn main_view(&self) -> Element<'_, Message> { fn main_view(&self) -> Element<'_, Message> {
let mut body = row![].width(Length::Fill).height(Length::Fill); let mut body = row![].width(Length::Fill).height(Length::Fill);
if !self.config.interface.sidebar_collapsed { if !self.config.interface.sidebar_collapsed {

View File

@@ -131,12 +131,32 @@ impl App {
); );
} }
} }
let composer = text_input("Ask DS4Server anything…", &self.composer) // Tab walks every focusable widget of every window, so a composer
.id(composer_id()) // left behind an open dialog would take a turn in that dialog's
.on_input(Message::ComposerChanged) // field order. Behind a modal it becomes a plain look-alike that
.on_submit(Message::SubmitPrompt) // cannot be focused; the modal dims it either way.
let composer: Element<'_, Message> = if self.modal_open() {
container(
text(if self.composer.is_empty() {
"Ask DS4Server anything…"
} else {
&self.composer
})
.size(14)
.color(muted_text()),
)
.padding(12) .padding(12)
.size(14); .width(Length::Fill)
.into()
} else {
text_input("Ask DS4Server anything…", &self.composer)
.id(composer_id())
.on_input(Message::ComposerChanged)
.on_submit(Message::SubmitPrompt)
.padding(12)
.size(14)
.into()
};
let action = if self.generating { let action = if self.generating {
action_button(text("Stop").size(12)).on_press(Message::StopGeneration) action_button(text("Stop").size(12)).on_press(Message::StopGeneration)
} else if self.composer.trim().is_empty() { } else if self.composer.trim().is_empty() {