From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-xtermjs 3/3] xterm.js: fix obstructed start button
Date: Wed, 2 Sep 2026 09:40:39 +0200 [thread overview]
Message-ID: <20260902074338.914500-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260902074338.914500-1-d.csapak@proxmox.com>
Depending on the window height, the xterm.js container sometimes
overlapped the 'start now' button in case a guest is not running. This
made it impossible to press that button.
Fix this by adding a 'display: none' CSS style when the terminal is
disconnected.
Reported in the forum:
https://forum.proxmox.com/threads/186055/
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
xterm.js/src/index.html.hbs.in | 2 +-
xterm.js/src/index.html.tpl.in | 2 +-
xterm.js/src/main.js | 26 ++++++++++++++++++++++++--
xterm.js/src/style.css | 4 ++++
4 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/xterm.js/src/index.html.hbs.in b/xterm.js/src/index.html.hbs.in
index 9857e9d..20c5814 100644
--- a/xterm.js/src/index.html.hbs.in
+++ b/xterm.js/src/index.html.hbs.in
@@ -18,7 +18,7 @@
<div id="connect_btn"><div> Start Now </div></div>
</div>
</div>
- <div id="terminal-container"></div>
+ <div id="terminal-container" class="disconnected"></div>
</div>
<script type="text/javascript">
if (typeof(PVE) === 'undefined') PVE = {};
diff --git a/xterm.js/src/index.html.tpl.in b/xterm.js/src/index.html.tpl.in
index 0084158..2d36c0e 100644
--- a/xterm.js/src/index.html.tpl.in
+++ b/xterm.js/src/index.html.tpl.in
@@ -18,7 +18,7 @@
<div id="connect_btn"><div> Start Now </div></div>
</div>
</div>
- <div id="terminal-container"></div>
+ <div id="terminal-container" class="disconnected"></div>
</div>
<script type="text/javascript">
if (typeof(PVE) === 'undefined') PVE = {};
diff --git a/xterm.js/src/main.js b/xterm.js/src/main.js
index e9097f1..66b00fa 100644
--- a/xterm.js/src/main.js
+++ b/xterm.js/src/main.js
@@ -47,36 +47,56 @@ function getBaseUrl() {
return baseUrl;
}
+function clearClasses(element) {
+ if (!element) {
+ return;
+ }
+
+ element.classList.values().forEach((cls) => element.classList.remove(cls));
+}
+
+function addClass(element, cls) {
+ if (!element || !cls) {
+ return;
+ }
+ element.classList.add(cls);
+}
+
const baseUrl = getBaseUrl();
const statusUrlSuffix = remote ? '/status' : '/status/current';
const startUrlSuffix = remote ? '/start' : '/status/start';
function updateState(newState, msg, code) {
- var timeout, severity, message;
+ var timeout, severity, message, cls;
switch (newState) {
case states.connecting:
+ cls = 'connecting';
message = 'Connecting...';
timeout = 0;
severity = severities.warning;
break;
case states.connected:
window.onbeforeunload = windowUnload;
+ cls = 'connected';
message = 'Connected';
break;
case states.disconnecting:
window.onbeforeunload = undefined;
+ cls = 'disconnected';
message = 'Disconnecting...';
timeout = 0;
severity = severities.warning;
break;
case states.reconnecting:
window.onbeforeunload = undefined;
+ cls = 'reconnecting';
message = 'Reconnecting...';
timeout = 0;
severity = severities.warning;
break;
case states.disconnected:
window.onbeforeunload = undefined;
+ cls = 'disconnected';
switch (state) {
case states.start:
case states.connecting:
@@ -106,6 +126,8 @@ function updateState(newState, msg, code) {
default:
throw 'unknown state';
}
+ clearClasses(terminalContainer);
+ addClass(terminalContainer, cls);
let msgArr = [];
if (msg) {
msgArr.push(msg);
@@ -227,7 +249,7 @@ function createTerminal() {
if (result.data.status === 'running') {
startConnection(params, term);
} else {
- document.getElementById('connect_dlg').classList.add('pve_open');
+ addClass(document.getElementById('connect_dlg'), 'pve_open');
}
},
failure: function (msg) {
diff --git a/xterm.js/src/style.css b/xterm.js/src/style.css
index 7962ae3..001b4c7 100644
--- a/xterm.js/src/style.css
+++ b/xterm.js/src/style.css
@@ -36,6 +36,10 @@ body {
width: auto;
}
+#terminal-container.disconnected {
+ display: none;
+}
+
#wrap {
height: 100%;
width: auto;
--
2.47.3
prev parent reply other threads:[~2026-09-02 7:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 7:40 [PATCH pve-xtermjs 0/3] xterm.js: fix obstructed start button Dominik Csapak
2026-09-02 7:40 ` [PATCH pve-xtermjs 1/3] xterm.js: add tidy make target Dominik Csapak
2026-09-02 7:40 ` [PATCH pve-xtermjs 2/3] xterm.js: run make tidy Dominik Csapak
2026-09-02 7:40 ` Dominik Csapak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902074338.914500-4-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox