Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions crates/rt-cef/src/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,25 @@ pub fn reposition() {
shown = true;
}
}
// During a prompt the status bar keeps the keyboard, on purpose.
let prompting = shell::with(|s| {
matches!(
if !shown {
return;
}
// During a prompt the keys belong to the status bar (see
// `shell::focus_for_prompt`), so it gets them back rather than the tab.
let back = shell::with(|s| {
let prompting = matches!(
s.engine.mode(),
rt_core::Mode::Prompt | rt_core::Mode::YesNo
)
);
if prompting {
s.statusbar.clone()
} else {
s.tabs.current().map(|t| t.view.clone())
}
})
.unwrap_or(false);
if shown
&& !prompting
&& let Some(tab) = shell::with(|s| s.tabs.current().map(|t| t.view.clone())).flatten()
{
crate::panes::focus_view(&tab);
.flatten();
if let Some(view) = back {
crate::panes::focus_view(&view);
}
}

Expand Down
37 changes: 37 additions & 0 deletions crates/rt-e2e/tests/lua_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,43 @@ end)
});
}

/// A float that appears while riptide asks something leaves the keyboard
/// with the question: real keys, not the test channel, which skips focus.
#[test]
#[ignore = "starts a browser; run with ./task e2e"]
fn a_float_shown_during_a_question_leaves_it_the_keyboard() {
let b = Browser::launch()
.lua(
r#"
rt.command("ask-then-float", function()
rt.ui.input({ prompt = "Password", secret = true }, function(text)
rt.notify("typed " .. tostring(text))
end)
rt.defer(300, function() rt.ui.float({ title = "Status", lines = { "working" } }) end)
end)
"#,
)
.start("page.html");
b.run("ask-then-float");
b.wait_mode("prompt");
b.wait_until("the float is placed", |s| {
s.floats.first().is_some_and(|f| f["placed"] == true)
});
let xdotool = |args: &[&str]| {
let status = std::process::Command::new("xdotool")
.args(args)
.env("DISPLAY", format!(":{}", b.display()))
.status()
.expect("xdotool");
assert!(status.success());
};
xdotool(&["type", "--delay", "20", "hunter2"]);
xdotool(&["key", "Return"]);
b.wait_until("the question got the keys", |s| {
s.message() == Some("typed hunter2")
});
}

#[test]
#[ignore = "starts a browser; run with ./task e2e"]
fn panels_dock_beside_the_page_and_take_keys_when_focused() {
Expand Down
Loading