Skip to content

Commit b55c948

Browse files
committed
Browser: clear focus in the old document before loading new document
1 parent c086961 commit b55c948

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

apps/browser/src/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ fn app() -> Element {
6161
let load_current_url = use_callback(move |_| {
6262
let request = (*history.current_url().read()).clone();
6363
*url_input_value.write_unchecked() = request.url.to_string();
64+
65+
if let Some(handle) = &*webview_node_handle.peek() {
66+
let node_id = handle.node_id();
67+
let mut doc = handle.doc_mut();
68+
if let Some(sub_doc) = doc
69+
.get_node_mut(node_id)
70+
.and_then(|node| node.element_data_mut())
71+
.and_then(|el| el.sub_doc_data_mut())
72+
{
73+
let mut sub_doc = sub_doc.inner_mut();
74+
sub_doc.clear_focus();
75+
}
76+
}
77+
6478
println!("Loading {}...", &request.url.as_str());
6579
loader.load_document(request);
6680
});

0 commit comments

Comments
 (0)