web: Ensure focus is not lost when copying text
Copying text creates a temporary textarea which is selected and focused. In order to preserve the focus of Ruffle, we need to move the focus into the container before removing the temporary textarea.
This commit is contained in:
parent
3e215610ca
commit
3253c9c964
|
@ -248,6 +248,7 @@ impl UiBackend for WebUiBackend {
|
|||
let editing_text = self.js_player.is_virtual_keyboard_focused();
|
||||
textarea.set_value(&content);
|
||||
let _ = element.append_child(&textarea);
|
||||
let _ = textarea.focus();
|
||||
textarea.select();
|
||||
|
||||
match document.exec_command("copy") {
|
||||
|
@ -261,6 +262,10 @@ impl UiBackend for WebUiBackend {
|
|||
Err(e) => tracing::error!("Couldn't set clipboard contents: {:?}", e),
|
||||
}
|
||||
|
||||
if let Ok(element) = element.clone().dyn_into::<HtmlElement>() {
|
||||
// Ensure we don't lose our focus.
|
||||
let _ = element.focus();
|
||||
}
|
||||
let _ = element.remove_child(&textarea);
|
||||
if editing_text {
|
||||
// Return focus to the text area
|
||||
|
|
Loading…
Reference in New Issue