From c2caaef5315d0c7bbbe0fa2c9decfe974c935abf Mon Sep 17 00:00:00 2001 From: Sucukdeluxe <259325684+Sucukdeluxe@users.noreply.github.com> Date: Thu, 15 Oct 2026 06:05:01 +0200 Subject: [PATCH] Stabilize menu motion and improve history retention controls --- renderer/app.js | 48 ++++++++++++++++++++++++++++++++--- renderer/styles.css | 61 ++++++++++++++++++++++++--------------------- 2 files changed, 77 insertions(+), 32 deletions(-) diff --git a/renderer/app.js b/renderer/app.js index c380013..e67dc9b 100644 --- a/renderer/app.js +++ b/renderer/app.js @@ -1680,6 +1680,7 @@ function _isHistoryTabActive() { const nextView = viewsById[`${tab.dataset.view}-view`]; if (nextView) nextView.classList.add('active'); if (tab.dataset.view === 'upload') requestAnimationFrame(clampRecentPanelHeight); + if (tab.dataset.view !== 'history') closeHistoryRetentionMenu(); activeTab = tab; syncTabIndicator(tab); const activeSidebarButton = nextView?.querySelector('.view-sidebar-navigation > .view-sidebar-item.active, .settings-navigation .settings-nav-button.active'); @@ -8833,20 +8834,52 @@ function syncHistoryRetentionPicker() { option.setAttribute('aria-selected', String(selected)); option.tabIndex = selected ? 0 : -1; }); + if (window.getComputedStyle(menu).display !== 'none') positionHistoryRetentionMenu(); +} + +function positionHistoryRetentionMenu() { + const trigger = document.getElementById('historyRetentionTrigger'); + const menu = document.getElementById('historyRetentionMenu'); + if (!trigger || !menu || window.getComputedStyle(menu).display === 'none') return; + const anchor = trigger.getBoundingClientRect(); + if (anchor.width === 0 || anchor.height === 0) { + closeHistoryRetentionMenu(); + return; + } + const padding = 12; + const gap = 6; + menu.style.minWidth = `${Math.min(window.innerWidth - padding * 2, Math.max(210, anchor.width))}px`; + menu.style.maxHeight = `${window.innerHeight - padding * 2}px`; + const naturalHeight = menu.scrollHeight + 2; + const below = Math.max(0, window.innerHeight - padding - anchor.bottom - gap); + const above = Math.max(0, anchor.top - padding - gap); + const opensUp = below < naturalHeight && above > below; + menu.style.maxHeight = `${Math.max(0, opensUp ? above : below)}px`; + const left = Math.max(padding, Math.min(anchor.left, window.innerWidth - padding - menu.offsetWidth)); + const top = opensUp ? anchor.top - gap - menu.offsetHeight : anchor.bottom + gap; + menu.style.left = `${Math.round(left)}px`; + menu.style.top = `${Math.round(Math.max(padding, Math.min(top, window.innerHeight - padding - menu.offsetHeight)))}px`; + menu.style.setProperty('--menu-entry-offset', opensUp ? '6px' : '-6px'); } function openHistoryRetentionMenu(focusOption = false) { const trigger = document.getElementById('historyRetentionTrigger'); const menu = document.getElementById('historyRetentionMenu'); if (!trigger || !menu) return; - historyRetentionMenuToken++; + const token = ++historyRetentionMenuToken; menu.classList.remove('menu-closing', 'menu-opening'); menu.style.display = 'block'; + positionHistoryRetentionMenu(); void menu.offsetHeight; menu.classList.add('menu-opening'); trigger.setAttribute('aria-expanded', 'true'); if (focusOption) { - window.requestAnimationFrame(() => menu.querySelector('[aria-selected="true"]')?.focus()); + window.requestAnimationFrame(() => { + if (historyRetentionMenuToken !== token || trigger.getAttribute('aria-expanded') !== 'true') return; + const option = menu.querySelector('[aria-selected="true"]'); + option?.focus({ preventScroll: true }); + if (option) menu.scrollTop = Math.max(0, option.offsetTop - (menu.clientHeight - option.offsetHeight) / 2); + }); } } @@ -8859,8 +8892,11 @@ function closeHistoryRetentionMenu(returnFocus = false) { void menu.offsetHeight; menu.classList.add('menu-closing'); trigger.setAttribute('aria-expanded', 'false'); - const finish = () => { - if (!Object.is(historyRetentionMenuToken, token)) return; + let finished = false; + const finish = (event) => { + if (event && event.target !== menu) return; + if (finished || !Object.is(historyRetentionMenuToken, token)) return; + finished = true; menu.style.display = 'none'; menu.classList.remove('menu-closing'); if (returnFocus) trigger.focus(); @@ -9689,6 +9725,10 @@ function setupListeners() { document.addEventListener('mousedown', event => { if (!historyRetentionPicker.contains(event.target)) closeHistoryRetentionMenu(); }); + window.addEventListener('resize', positionHistoryRetentionMenu); + document.addEventListener('scroll', event => { + if (!historyRetentionMenu.contains(event.target)) positionHistoryRetentionMenu(); + }, true); const historyRetentionSelect = document.getElementById('historyRetentionSelect'); if (historyRetentionSelect) { diff --git a/renderer/styles.css b/renderer/styles.css index c1b29a7..ecdeb52 100644 --- a/renderer/styles.css +++ b/renderer/styles.css @@ -1890,24 +1890,25 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; } .history-container { padding: 16px; overflow: auto; flex: 1; background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent 24%); } .history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; } .history-header h2 { font-size: 18px; } -.history-retention-label { font-size: 13px; line-height: 16px; color: var(--text-dim); margin-right: 2px; transform: translateY(-1px); } +.history-retention-label { font-size: 14px; line-height: 20px; color: var(--text-muted); margin-right: 2px; } .history-retention-picker { position: relative; - min-width: 150px; + min-width: 184px; } .btn.history-retention-trigger { width: 100%; - min-width: 150px; + min-width: 184px; min-height: 34px; height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 14px; - padding-inline: 11px; + padding-inline: 14px; color: var(--text); - font-size: 13px; - line-height: 16px; + font-family: inherit; + font-size: 14px; + line-height: 20px; text-align: left; } .history-retention-trigger[aria-expanded="true"] { @@ -1927,13 +1928,14 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; } transform: translateY(2px) rotate(225deg); } .history-retention-menu { - position: absolute; - top: calc(100% + 6px); - left: 0; + position: fixed; z-index: 1200; width: max-content; - min-width: 100%; - padding: 5px; + min-width: 210px; + max-width: calc(100vw - 24px); + overflow-y: auto; + overscroll-behavior: contain; + padding: 6px; border: 1px solid var(--border-hover); border-radius: 7px; background: var(--bg-raised); @@ -1942,18 +1944,21 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; } } .history-retention-option { width: 100%; - min-height: 31px; + min-height: 40px; display: flex; align-items: center; - padding: 0 10px; + padding: 9px 12px; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); font: inherit; - font-size: 12px; - font-weight: 600; - white-space: nowrap; + font-size: 14px; + line-height: 20px; + font-weight: 500; + text-align: left; + white-space: normal; + overflow-wrap: anywhere; cursor: pointer; } .history-retention-option:hover, @@ -2186,14 +2191,6 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; } transition-duration: 360ms !important; } - .menu-opening { - animation-duration: 180ms !important; - } - - .menu-closing { - animation-duration: 160ms !important; - } - .account-collapse { transition-duration: 220ms, 160ms, 0s !important; } @@ -2986,13 +2983,13 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; } } @keyframes menu-unfold { - from { opacity: .35; clip-path: inset(0 0 100% 0); transform: scaleY(.96); } - to { opacity: 1; clip-path: inset(0); transform: scaleY(1); } + from { opacity: 0; transform: translateY(var(--menu-entry-offset, -6px)); } + to { opacity: 1; transform: translateY(0); } } @keyframes menu-fold { - from { opacity: 1; clip-path: inset(0); transform: scaleY(1); } - to { opacity: .2; clip-path: inset(0 0 100% 0); transform: scaleY(.96); } + from { opacity: 1; transform: translateY(0); } + to { opacity: 0; transform: translateY(var(--menu-entry-offset, -6px)); } } .header-utilities .menu-dropdown { @@ -4771,6 +4768,9 @@ input[type="checkbox"] { min-width: 0; } +.history-header { flex-wrap: wrap; gap: 10px 16px; } +.history-header > h2 { flex: 0 0 auto; white-space: nowrap; } + .history-retention-select { min-width: 150px; } @@ -5757,3 +5757,8 @@ input[type="checkbox"] { color: #b9c2d0; font-size: 12px; } + +#history-view .view-sidebar-section-label { font-size: 12px; } +#history-view .view-sidebar-summary { font-size: 13px; } +#history-view .view-sidebar-summary strong { font-size: 14px; } +#history-view .view-sidebar-footnote { font-size: 12px; }