Misc · Web: the web view hands the keyboard back

WKWebView takes AppKit's first responder on a press and gpui's view
never asks for it back, so typed text went to the page for good. The
web view now hands it back through wry's focus_parent on every press
gpui gets and when its page drops. The gallery proves it with a native
key after a press on the page. in_view builds only where it is used,
its test covers a box that straddles the view's top, and the embed's
frame takes the card's bottom corners.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-28 04:59:11 -04:00
1 parent 012a6e3105
commit c7c4c006a7
6 files changed
+52 -10

No files matched your search

+7
View File
@@ -66,6 +66,13 @@ pub const PAGE: Page = Page {
Step::UpAt("cookies", 230.0, 84.0),
Step::HoverAt("cookies", 20.0, 20.0),
Step::Shot("cookies-choosing"),
Step::DownAt("web", 240.0, 100.0),
Step::UpAt("web", 240.0, 100.0),
Step::DownAt("converter", 24.0, 60.0),
Step::UpAt("converter", 24.0, 60.0),
Step::Key("cmd-a"),
Step::NativeKey("5"),
Step::Shot("keys-back"),
],
};
+4 -2
View File
@@ -1,6 +1,7 @@
use ely_gpui_component::misc::{IframeEmbed, WebSource, WebView};
use gpui::{App, IntoElement, ParentElement, Styled, div, px};
use crate::probe::probe;
use crate::ui::{blocked, section};
const PAGE: &str = r#"<!doctype html>
@@ -25,12 +26,13 @@ pub fn render(cx: &App) -> impl IntoElement + use<> {
"A native web view laid over its box: an address, or HTML the owner hands in, which makes it an HTML preview. It draws above everything gpui paints and follows the box each frame.",
cx,
)
.child(
.child(probe(
"web",
div()
.w(px(480.0))
.h(px(200.0))
.child(WebView::new("web", WebSource::Html(PAGE.into()))),
),
)),
)
.child(
section(
+7 -3
View File
@@ -46,7 +46,7 @@ pub enum Step {
ExpectClosed(&'static str),
/// Photographs this app's frontmost popup, such as the share picker.
ShotPopup(&'static str),
/// Posts a key to AppKit itself; only `escape` is known.
/// Posts a key down to AppKit itself; `escape` and `5` are known.
NativeKey(&'static str),
/// Cancels the open file panel, whose content runs out of process.
CancelPanel,
@@ -210,9 +210,13 @@ pub async fn play(
log::info!("script: wrote {}", file.display());
}
Step::NativeKey(key) => {
anyhow::ensure!(key == "escape", "native key {key} is not known");
let (text, code) = match key {
"escape" => ("\u{1b}", 53),
"5" => ("5", 23),
other => anyhow::bail!("native key {other} is not known"),
};
let number = window.update(cx, |_, window, _| number(window))??;
post_key(number, true, "\u{1b}", 53)?;
post_key(number, true, text, code)?;
}
Step::CancelPanel => cancel_panel()?,
Step::ExpectClosed(key) => {