From 4b968850164f9c2d6bb4aced1b87fd9d6934d875 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Fri, 27 Nov 2026 15:37:09 +0100 Subject: [PATCH] Fix: stop web dialogs closing on text-selection drags All modal overlays closed on a click whose target was the backdrop, but browsers dispatch that click to the nearest common ancestor of mousedown and mouseup: selecting text inside an input and releasing outside the card closed the dialog. The overlays now ignore backdrop clicks and close only from their own buttons (x / Cancel / confirm); app-dialog keeps Escape. Review follow-ups in the same flow: a late set_device_remark/group reply is applied only to the dialog still open for the same device (failure replies now echo the device id, and the success path no longer fetches the list twice), Save reports "not connected" instead of doing nothing while the socket reconnects, and the remark/group menu icons get their colours. Also escape client-reported card fields for HTML and attribute contexts (screen, transfer/active-window titles, audit timestamp title), so a modified host cannot inject markup into the admin page. Verified: node --check on the inline script; go build ./... and go test ./web/ pass; the embedded asset copy is in sync. Co-Authored-By: deepseek-flash --- server/go/web/ws_handlers.go | 8 +++++-- server/web/index.html | 43 +++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/server/go/web/ws_handlers.go b/server/go/web/ws_handlers.go index b24afa7..7b39254 100644 --- a/server/go/web/ws_handlers.go +++ b/server/go/web/ws_handlers.go @@ -1806,7 +1806,9 @@ func (h *wsHub) handleSetDeviceRemark(c *wsClient, raw []byte) { "reason": reason, "error": msg, }) - c.queue(mustJSON(map[string]any{"cmd": replyCmd, "ok": false, "msg": msg})) + // id lets the page drop a late reply meant for a dialog it has since + // closed and replaced with another device's. + c.queue(mustJSON(map[string]any{"cmd": replyCmd, "ok": false, "id": id, "msg": msg})) } // An unparsable payload (e.g. a non-string remark) must be rejected, not // treated as an empty remark: empty clears the label. @@ -1877,7 +1879,9 @@ func (h *wsHub) handleSetDeviceGroup(c *wsClient, raw []byte) { "reason": reason, "error": msg, }) - c.queue(mustJSON(map[string]any{"cmd": replyCmd, "ok": false, "msg": msg})) + // id lets the page drop a late reply meant for a dialog it has since + // closed and replaced with another device's. + c.queue(mustJSON(map[string]any{"cmd": replyCmd, "ok": false, "id": id, "msg": msg})) } if err := json.Unmarshal(raw, &in); err != nil { fail("Invalid request", "invalid_request") diff --git a/server/web/index.html b/server/web/index.html index e033650..497613a 100644 --- a/server/web/index.html +++ b/server/web/index.html @@ -725,6 +725,8 @@ margin-top: 1px; } .card-menu-item.term .card-menu-icon { color: #4caf50; } + .card-menu-item.edit .card-menu-icon { color: #4dabf7; } + .card-menu-item.group .card-menu-icon { color: #b197fc; } .card-menu-item.bind .card-menu-icon { color: #e67e22; } .card-menu-item.transfer .card-menu-icon { color: #d68910; } .card-menu-item.del .card-menu-icon { color: #e74c3c; } @@ -2193,7 +2195,7 @@ -