Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Refine inline URL editor event handling

rcourtman30b78784e087
diff --git a/frontend-modern/src/components/Dashboard/GuestRow.tsx b/frontend-modern/src/components/Dashboard/GuestRow.tsx
index fd19a026ba..e8ce81460a 100644
--- a/frontend-modern/src/components/Dashboard/GuestRow.tsx
+++ b/frontend-modern/src/components/Dashboard/GuestRow.tsx
@@ -187,16 +187,22 @@ export function GuestRow(props: GuestRowProps) {
}
});
+ // Track if we're currently editing to prevent cleanup during re-renders
+ let isCurrentlyMounted = true;
+
// Add global click handler to close editor and prevent clicks while editing
createEffect(() => {
- if (isEditingUrl()) {
+ if (isEditingUrl() && isCurrentlyMounted) {
const handleGlobalClick = (e: MouseEvent) => {
+ // Double-check we're still the editing guest
+ if (currentlyEditingGuestId() !== guestId()) return;
+
const target = e.target as HTMLElement;
// Allow clicking another guest name to switch editing
const isClickingGuestName = target.closest('[data-guest-name-editable]');
// If clicking outside the editor (and not another guest name), close it and prevent the click
- if (!target.closest('[data-url-editor]') && !isClickingGuestName && currentlyEditingGuestId() === guestId()) {
+ if (!target.closest('[data-url-editor]') && !isClickingGuestName) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
@@ -205,10 +211,13 @@ export function GuestRow(props: GuestRowProps) {
};
const handleGlobalMouseDown = (e: MouseEvent) => {
+ // Double-check we're still the editing guest
+ if (currentlyEditingGuestId() !== guestId()) return;
+
const target = e.target as HTMLElement;
const isClickingGuestName = target.closest('[data-guest-name-editable]');
- if (!target.closest('[data-url-editor]') && !isClickingGuestName && currentlyEditingGuestId() === guestId()) {
+ if (!target.closest('[data-url-editor]') && !isClickingGuestName) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
@@ -453,13 +462,6 @@ export function GuestRow(props: GuestRowProps) {
editingValues.set(guestId(), e.currentTarget.value);
setEditingValuesVersion(v => v + 1);
}}
- onBlur={(e) => {
- // Close editor when clicking away, but not if clicking the save/delete buttons
- const relatedTarget = e.relatedTarget as HTMLElement;
- if (!relatedTarget || !relatedTarget.closest('[data-url-editor-button]')) {
- cancelEditingUrl();
- }
- }}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.preventDefault();