BlueGit

timfa filemanager

Prevent update badge snap when closing user menu

timfa Tim Falken · pushed by timfa

Authored 2026-05-17 · 6 months ago

Hash
551aa4c5d2f6bc04d5a07286dbf636095d19367f
Parent
d22405f0
2 files changed +21 −7
.github/technical-reference.md +1 −1
@@ -172,7 +172,7 @@
172 172 - applyFolderThumbnail(iconEl, srcUrl) - Injects an SVG <image> element clipped to the folder outline path into the folder's icon SVG.
173 173 - initTopbarDropdowns() / closeTopbarDropdowns() - Controls Upload/User roll-down menus (open/close, outside-click close, Escape close) without resizing the top bar.
174 174 - setAdminUpdateBadge(count) - Renders the update-count badge and coordinates its anchor between User trigger and Admin menu item.
175 - syncAdminUpdateBadgeAnchor() / animateBadgeToTarget(targetEl) - Moves the update badge between User trigger and Admin menu item with a smooth transition while the User dropdown opens/closes.
175 - syncAdminUpdateBadgeAnchor() / animateBadgeToTarget(targetEl) / moveBadgeToTarget(targetEl) - Animates badge movement while opening User dropdown and uses a non-animated move on close to prevent snap-to-corner geometry glitches.
176 176 - openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail files from the folder (including video thumbnails); allows selection, clearing, and cancellation.
177 177 - openIconPickerModal(options) - Shared icon-picker modal used by folder-icon and global-favicon flows; includes live thumbnail-name filtering.
178 178 - openGlobalFaviconPicker() - Opens a debounced, server-backed image-search modal across all accessible roots and sets/clears global favicon via `/files/global-favicon`.
@@ -172,7 +172,7 @@
172- applyFolderThumbnail(iconEl, srcUrl) - Injects an SVG <image> element clipped to the folder outline path into the folder's icon SVG.
172- applyFolderThumbnail(iconEl, srcUrl) - Injects an SVG <image> element clipped to the folder outline path into the folder's icon SVG.
173- initTopbarDropdowns() / closeTopbarDropdowns() - Controls Upload/User roll-down menus (open/close, outside-click close, Escape close) without resizing the top bar.
173- initTopbarDropdowns() / closeTopbarDropdowns() - Controls Upload/User roll-down menus (open/close, outside-click close, Escape close) without resizing the top bar.
174- setAdminUpdateBadge(count) - Renders the update-count badge and coordinates its anchor between User trigger and Admin menu item.
174- setAdminUpdateBadge(count) - Renders the update-count badge and coordinates its anchor between User trigger and Admin menu item.
175- syncAdminUpdateBadgeAnchor() / animateBadgeToTarget(targetEl) - Moves the update badge between User trigger and Admin menu item with a smooth transition while the User dropdown opens/closes.
175- syncAdminUpdateBadgeAnchor() / animateBadgeToTarget(targetEl) / moveBadgeToTarget(targetEl) - Animates badge movement while opening User dropdown and uses a non-animated move on close to prevent snap-to-corner geometry glitches.
176- openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail files from the folder (including video thumbnails); allows selection, clearing, and cancellation.
176- openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail files from the folder (including video thumbnails); allows selection, clearing, and cancellation.
177- openIconPickerModal(options) - Shared icon-picker modal used by folder-icon and global-favicon flows; includes live thumbnail-name filtering.
177- openIconPickerModal(options) - Shared icon-picker modal used by folder-icon and global-favicon flows; includes live thumbnail-name filtering.
178- openGlobalFaviconPicker() - Opens a debounced, server-backed image-search modal across all accessible roots and sets/clears global favicon via `/files/global-favicon`.
178- openGlobalFaviconPicker() - Opens a debounced, server-backed image-search modal across all accessible roots and sets/clears global favicon via `/files/global-favicon`.
public/app.js +20 −6
@@ -5015,7 +5015,19 @@ function animateBadgeToTarget (targetEl)
5015 5015 badge.addEventListener('transitionend', cleanup);
5016 5016 }
5017 5017
5018 function syncAdminUpdateBadgeAnchor ()
5018 function moveBadgeToTarget (targetEl)
5019 {
5020 const badge = document.getElementById('admin-update-badge');
5021 if (!badge || !targetEl) return;
5022 if (badge.parentElement === targetEl) return;
5023
5024 badge.style.transition = '';
5025 badge.style.transform = '';
5026 badge.style.willChange = '';
5027 targetEl.appendChild(badge);
5028 }
5029
5030 function syncAdminUpdateBadgeAnchor ({ animate = true, forceUserAnchor = false } = {})
5019 5031 {
5020 5032 const badge = document.getElementById('admin-update-badge');
5021 5033 const userMenuBtn = document.getElementById('btn-user-menu');
@@ -5024,15 +5036,16 @@ function syncAdminUpdateBadgeAnchor ()
5024 5036
5025 5037 const userDropdown = userMenuBtn.closest('.topbar-dropdown');
5026 5038 const userMenuOpen = !!(userDropdown && userDropdown.classList.contains('open'));
5027 const target = userMenuOpen ? adminBtn : userMenuBtn;
5039 const target = forceUserAnchor ? userMenuBtn : (userMenuOpen ? adminBtn : userMenuBtn);
5028 5040
5029 5041 if (badge.classList.contains('hidden'))
5030 5042 {
5031 if (badge.parentElement !== userMenuBtn) userMenuBtn.appendChild(badge);
5043 moveBadgeToTarget(userMenuBtn);
5032 5044 return;
5033 5045 }
5034 5046
5035 animateBadgeToTarget(target);
5047 if (animate) animateBadgeToTarget(target);
5048 else moveBadgeToTarget(target);
5036 5049 }
5037 5050
5038 5051 function setAdminUpdateBadge (count)
@@ -5930,14 +5943,15 @@ function applyFolderThumbnail (iconEl, srcUrl)
5930 5943
5931 5944 function closeTopbarDropdowns ()
5932 5945 {
5946 // Prevent jump-to-(0,0) glitches by snapping badge back before the menu is hidden.
5947 syncAdminUpdateBadgeAnchor({ animate: false, forceUserAnchor: true });
5948
5933 5949 document.querySelectorAll('.topbar-dropdown.open').forEach((dropdown) =>
5934 5950 {
5935 5951 dropdown.classList.remove('open');
5936 5952 const trigger = dropdown.querySelector('button[aria-expanded]');
5937 5953 if (trigger) trigger.setAttribute('aria-expanded', 'false');
5938 5954 });
5939
5940 syncAdminUpdateBadgeAnchor();
5941 5955 }
5942 5956
5943 5957 function initTopbarDropdowns ()
@@ -5015,7 +5015,19 @@ function animateBadgeToTarget (targetEl)
5015 badge.addEventListener('transitionend', cleanup);
5015 badge.addEventListener('transitionend', cleanup);
5016}
5016}
5017
5017
5018function syncAdminUpdateBadgeAnchor ()
5018function moveBadgeToTarget (targetEl)
5019{
5020 const badge = document.getElementById('admin-update-badge');
5021 if (!badge || !targetEl) return;
5022 if (badge.parentElement === targetEl) return;
5023
5024 badge.style.transition = '';
5025 badge.style.transform = '';
5026 badge.style.willChange = '';
5027 targetEl.appendChild(badge);
5028}
5029
5030function syncAdminUpdateBadgeAnchor ({ animate = true, forceUserAnchor = false } = {})
5019{
5031{
5020 const badge = document.getElementById('admin-update-badge');
5032 const badge = document.getElementById('admin-update-badge');
5021 const userMenuBtn = document.getElementById('btn-user-menu');
5033 const userMenuBtn = document.getElementById('btn-user-menu');
@@ -5024,15 +5036,16 @@ function syncAdminUpdateBadgeAnchor ()
5024
5036
5025 const userDropdown = userMenuBtn.closest('.topbar-dropdown');
5037 const userDropdown = userMenuBtn.closest('.topbar-dropdown');
5026 const userMenuOpen = !!(userDropdown && userDropdown.classList.contains('open'));
5038 const userMenuOpen = !!(userDropdown && userDropdown.classList.contains('open'));
5027 const target = userMenuOpen ? adminBtn : userMenuBtn;
5039 const target = forceUserAnchor ? userMenuBtn : (userMenuOpen ? adminBtn : userMenuBtn);
5028
5040
5029 if (badge.classList.contains('hidden'))
5041 if (badge.classList.contains('hidden'))
5030 {
5042 {
5031 if (badge.parentElement !== userMenuBtn) userMenuBtn.appendChild(badge);
5043 moveBadgeToTarget(userMenuBtn);
5032 return;
5044 return;
5033 }
5045 }
5034
5046
5035 animateBadgeToTarget(target);
5047 if (animate) animateBadgeToTarget(target);
5048 else moveBadgeToTarget(target);
5036}
5049}
5037
5050
5038function setAdminUpdateBadge (count)
5051function setAdminUpdateBadge (count)
@@ -5930,14 +5943,15 @@ function applyFolderThumbnail (iconEl, srcUrl)
5930
5943
5931function closeTopbarDropdowns ()
5944function closeTopbarDropdowns ()
5932{
5945{
5946 // Prevent jump-to-(0,0) glitches by snapping badge back before the menu is hidden.
5947 syncAdminUpdateBadgeAnchor({ animate: false, forceUserAnchor: true });
5948
5933 document.querySelectorAll('.topbar-dropdown.open').forEach((dropdown) =>
5949 document.querySelectorAll('.topbar-dropdown.open').forEach((dropdown) =>
5934 {
5950 {
5935 dropdown.classList.remove('open');
5951 dropdown.classList.remove('open');
5936 const trigger = dropdown.querySelector('button[aria-expanded]');
5952 const trigger = dropdown.querySelector('button[aria-expanded]');
5937 if (trigger) trigger.setAttribute('aria-expanded', 'false');
5953 if (trigger) trigger.setAttribute('aria-expanded', 'false');
5938 });
5954 });
5939
5940 syncAdminUpdateBadgeAnchor();
5941}
5955}
5942
5956
5943function initTopbarDropdowns ()
5957function initTopbarDropdowns ()