grab focus only on request entry is empty

This commit is contained in:
yggverse 2025-01-26 10:54:28 +02:00
parent 2b472eb618
commit 3e89b5e05e
3 changed files with 10 additions and 6 deletions

View File

@ -47,7 +47,7 @@ impl Window {
move |position, request, is_pinned, is_selected, is_attention, is_load| {
tab.append(
position,
request,
request.as_deref(),
is_pinned,
is_selected,
is_attention,
@ -122,7 +122,7 @@ impl Window {
action.open.on_activate({
let tab = tab.clone();
move |_, request| {
tab.append(Position::End, Some(request), false, true, false, true);
tab.append(Position::End, Some(&request), false, true, false, true);
}
});

View File

@ -152,7 +152,7 @@ impl Tab {
pub fn append(
&self,
position: Position,
request: Option<String>,
request: Option<&str>,
is_pinned: bool,
is_selected: bool,
is_attention: bool,
@ -175,13 +175,17 @@ impl Tab {
),
));
// Expect user input on tab appended has empty request entry
// * this action initiated here because should be applied on tab appending event only
if request.is_none() || request.is_some_and(|value| value.is_empty()) {
item.page.navigation.request.widget.entry.grab_focus();
}
// Register dynamically created tab components in the HashMap index
self.index
.borrow_mut()
.insert(item.id.clone(), item.clone());
item.page.navigation.request.widget.entry.grab_focus();
item
}

View File

@ -45,7 +45,7 @@ impl Item {
),
(position, request, is_pinned, is_selected, is_attention, is_load): (
Position,
Option<String>,
Option<&str>,
bool,
bool,
bool,