fix(web): focus terminal on init (#4325)
Always focus the terminal during init instead of on a mouse event.
This commit is contained in:
parent
aaa843eee0
commit
ae8981f7a0
2 changed files with 6 additions and 3 deletions
|
|
@ -91,7 +91,6 @@ export function setupInputHandlers(term, sendFunction) {
|
||||||
// Mouse movement handler
|
// Mouse movement handler
|
||||||
let terminal_element = document.getElementById("terminal");
|
let terminal_element = document.getElementById("terminal");
|
||||||
terminal_element.addEventListener("mousemove", function (event) {
|
terminal_element.addEventListener("mousemove", function (event) {
|
||||||
window.term.focus();
|
|
||||||
// this is a hack around: https://github.com/xtermjs/xterm.js/issues/1062
|
// this is a hack around: https://github.com/xtermjs/xterm.js/issues/1062
|
||||||
// in short, xterm.js doesn't listen to mousemove at all and so even though
|
// in short, xterm.js doesn't listen to mousemove at all and so even though
|
||||||
// we send it a request for AnyEvent mouse handling, we don't get motion events in return
|
// we send it a request for AnyEvent mouse handling, we don't get motion events in return
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* Terminal initialization and management
|
* Terminal initialization and management
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { build_link_handler } from './links.js';
|
import { build_link_handler } from "./links.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the terminal with all required addons and configuration
|
* Initialize the terminal with all required addons and configuration
|
||||||
|
|
@ -20,7 +20,10 @@ export function initTerminal() {
|
||||||
const clipboardAddon = new ClipboardAddon.ClipboardAddon();
|
const clipboardAddon = new ClipboardAddon.ClipboardAddon();
|
||||||
|
|
||||||
const { linkHandler, activateLink } = build_link_handler();
|
const { linkHandler, activateLink } = build_link_handler();
|
||||||
const webLinksAddon = new WebLinksAddon.WebLinksAddon(activateLink, linkHandler);
|
const webLinksAddon = new WebLinksAddon.WebLinksAddon(
|
||||||
|
activateLink,
|
||||||
|
linkHandler
|
||||||
|
);
|
||||||
term.options.linkHandler = linkHandler;
|
term.options.linkHandler = linkHandler;
|
||||||
|
|
||||||
const webglAddon = new WebglAddon.WebglAddon();
|
const webglAddon = new WebglAddon.WebglAddon();
|
||||||
|
|
@ -34,5 +37,6 @@ export function initTerminal() {
|
||||||
term.loadAddon(webglAddon);
|
term.loadAddon(webglAddon);
|
||||||
term.open(document.getElementById("terminal"));
|
term.open(document.getElementById("terminal"));
|
||||||
fitAddon.fit();
|
fitAddon.fit();
|
||||||
|
term.focus();
|
||||||
return { term, fitAddon };
|
return { term, fitAddon };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue