From 8960e7dca31d3f12a20df756f95353df5a0acb9a Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Fri, 13 Mar 2026 18:43:07 +0300 Subject: [PATCH] Fix anchor positions getting corrupted by fullscreen mode Skip persisting minimap/toolbar anchor data while in fullscreen so dragging during fullscreen doesn't overwrite normal-mode offsets. ResizeObserver now just clamps during fullscreen instead of re-applying normal-mode anchors to the fullscreen-sized container. Co-Authored-By: Claude Opus 4.6 --- .../static/js/features/graph-editor.js | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/server/src/wled_controller/static/js/features/graph-editor.js b/server/src/wled_controller/static/js/features/graph-editor.js index dc932f0..cc61de2 100644 --- a/server/src/wled_controller/static/js/features/graph-editor.js +++ b/server/src/wled_controller/static/js/features/graph-editor.js @@ -100,9 +100,18 @@ function _applyAnchor(el, container, saved) { el.style.left = l + 'px'; el.style.top = t + 'px'; } -/** Shorthand wrappers for minimap / toolbar. */ -function _saveMinimapAnchored(el, container) { return _saveAnchored(el, container, _saveMinimapRect); } -function _saveToolbarAnchored(el, container) { return _saveAnchored(el, container, _saveToolbarPos); } +/** True when the graph container is in fullscreen — suppress anchor persistence. */ +function _isFullscreen() { return !!document.fullscreenElement; } + +/** Shorthand wrappers for minimap / toolbar (skip save in fullscreen). */ +function _saveMinimapAnchored(el, container) { + if (_isFullscreen()) return; + return _saveAnchored(el, container, _saveMinimapRect); +} +function _saveToolbarAnchored(el, container) { + if (_isFullscreen()) return; + return _saveAnchored(el, container, _saveToolbarPos); +} // Toolbar position persisted in localStorage const _TB_KEY = 'graph_toolbar'; @@ -867,22 +876,32 @@ let _resizeObserver = null; function _initResizeClamp(container) { if (_resizeObserver) _resizeObserver.disconnect(); _resizeObserver = new ResizeObserver(() => { + // In fullscreen, just clamp — don't re-anchor from normal-mode saved data + const fs = _isFullscreen(); const mm = container.querySelector('.graph-minimap'); const tb = container.querySelector('.graph-toolbar'); if (mm) { - const saved = _loadMinimapRect(); - if (saved?.anchor) { - _applyAnchor(mm, container, saved); - } else { + if (fs) { _clampElementInContainer(mm, container); + } else { + const saved = _loadMinimapRect(); + if (saved?.anchor) { + _applyAnchor(mm, container, saved); + } else { + _clampElementInContainer(mm, container); + } } } if (tb) { - const saved = _loadToolbarPos(); - if (saved?.anchor) { - _applyAnchor(tb, container, saved); - } else { + if (fs) { _clampElementInContainer(tb, container); + } else { + const saved = _loadToolbarPos(); + if (saved?.anchor) { + _applyAnchor(tb, container, saved); + } else { + _clampElementInContainer(tb, container); + } } } });