Stabilize menu motion and improve history retention controls
CI / verify (push) Canceled after 0s

This commit is contained in:
Sucukdeluxe committed 2026-10-15 06:05:01 +02:00
1 parent 9542c0f0eb
commit c2caaef531
2 files changed
+77 -32

No files matched your search

+44 -4
View File
@@ -1680,6 +1680,7 @@ function _isHistoryTabActive() {
const nextView = viewsById[`${tab.dataset.view}-view`]; const nextView = viewsById[`${tab.dataset.view}-view`];
if (nextView) nextView.classList.add('active'); if (nextView) nextView.classList.add('active');
if (tab.dataset.view === 'upload') requestAnimationFrame(clampRecentPanelHeight); if (tab.dataset.view === 'upload') requestAnimationFrame(clampRecentPanelHeight);
if (tab.dataset.view !== 'history') closeHistoryRetentionMenu();
activeTab = tab; activeTab = tab;
syncTabIndicator(tab); syncTabIndicator(tab);
const activeSidebarButton = nextView?.querySelector('.view-sidebar-navigation > .view-sidebar-item.active, .settings-navigation .settings-nav-button.active'); 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.setAttribute('aria-selected', String(selected));
option.tabIndex = selected ? 0 : -1; 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) { function openHistoryRetentionMenu(focusOption = false) {
const trigger = document.getElementById('historyRetentionTrigger'); const trigger = document.getElementById('historyRetentionTrigger');
const menu = document.getElementById('historyRetentionMenu'); const menu = document.getElementById('historyRetentionMenu');
if (!trigger || !menu) return; if (!trigger || !menu) return;
historyRetentionMenuToken++; const token = ++historyRetentionMenuToken;
menu.classList.remove('menu-closing', 'menu-opening'); menu.classList.remove('menu-closing', 'menu-opening');
menu.style.display = 'block'; menu.style.display = 'block';
positionHistoryRetentionMenu();
void menu.offsetHeight; void menu.offsetHeight;
menu.classList.add('menu-opening'); menu.classList.add('menu-opening');
trigger.setAttribute('aria-expanded', 'true'); trigger.setAttribute('aria-expanded', 'true');
if (focusOption) { 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; void menu.offsetHeight;
menu.classList.add('menu-closing'); menu.classList.add('menu-closing');
trigger.setAttribute('aria-expanded', 'false'); trigger.setAttribute('aria-expanded', 'false');
const finish = () => { let finished = false;
if (!Object.is(historyRetentionMenuToken, token)) return; const finish = (event) => {
if (event && event.target !== menu) return;
if (finished || !Object.is(historyRetentionMenuToken, token)) return;
finished = true;
menu.style.display = 'none'; menu.style.display = 'none';
menu.classList.remove('menu-closing'); menu.classList.remove('menu-closing');
if (returnFocus) trigger.focus(); if (returnFocus) trigger.focus();
@@ -9689,6 +9725,10 @@ function setupListeners() {
document.addEventListener('mousedown', event => { document.addEventListener('mousedown', event => {
if (!historyRetentionPicker.contains(event.target)) closeHistoryRetentionMenu(); 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'); const historyRetentionSelect = document.getElementById('historyRetentionSelect');
if (historyRetentionSelect) { if (historyRetentionSelect) {
+33 -28
View File
@@ -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-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 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.history-header h2 { font-size: 18px; } .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 { .history-retention-picker {
position: relative; position: relative;
min-width: 150px; min-width: 184px;
} }
.btn.history-retention-trigger { .btn.history-retention-trigger {
width: 100%; width: 100%;
min-width: 150px; min-width: 184px;
min-height: 34px; min-height: 34px;
height: 34px; height: 34px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 14px; gap: 14px;
padding-inline: 11px; padding-inline: 14px;
color: var(--text); color: var(--text);
font-size: 13px; font-family: inherit;
line-height: 16px; font-size: 14px;
line-height: 20px;
text-align: left; text-align: left;
} }
.history-retention-trigger[aria-expanded="true"] { .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); transform: translateY(2px) rotate(225deg);
} }
.history-retention-menu { .history-retention-menu {
position: absolute; position: fixed;
top: calc(100% + 6px);
left: 0;
z-index: 1200; z-index: 1200;
width: max-content; width: max-content;
min-width: 100%; min-width: 210px;
padding: 5px; max-width: calc(100vw - 24px);
overflow-y: auto;
overscroll-behavior: contain;
padding: 6px;
border: 1px solid var(--border-hover); border: 1px solid var(--border-hover);
border-radius: 7px; border-radius: 7px;
background: var(--bg-raised); background: var(--bg-raised);
@@ -1942,18 +1944,21 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; }
} }
.history-retention-option { .history-retention-option {
width: 100%; width: 100%;
min-height: 31px; min-height: 40px;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 10px; padding: 9px 12px;
border: 0; border: 0;
border-radius: 5px; border-radius: 5px;
background: transparent; background: transparent;
color: var(--text-muted); color: var(--text-muted);
font: inherit; font: inherit;
font-size: 12px; font-size: 14px;
font-weight: 600; line-height: 20px;
white-space: nowrap; font-weight: 500;
text-align: left;
white-space: normal;
overflow-wrap: anywhere;
cursor: pointer; cursor: pointer;
} }
.history-retention-option:hover, .history-retention-option:hover,
@@ -2186,14 +2191,6 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; }
transition-duration: 360ms !important; transition-duration: 360ms !important;
} }
.menu-opening {
animation-duration: 180ms !important;
}
.menu-closing {
animation-duration: 160ms !important;
}
.account-collapse { .account-collapse {
transition-duration: 220ms, 160ms, 0s !important; transition-duration: 220ms, 160ms, 0s !important;
} }
@@ -2986,13 +2983,13 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; }
} }
@keyframes menu-unfold { @keyframes menu-unfold {
from { opacity: .35; clip-path: inset(0 0 100% 0); transform: scaleY(.96); } from { opacity: 0; transform: translateY(var(--menu-entry-offset, -6px)); }
to { opacity: 1; clip-path: inset(0); transform: scaleY(1); } to { opacity: 1; transform: translateY(0); }
} }
@keyframes menu-fold { @keyframes menu-fold {
from { opacity: 1; clip-path: inset(0); transform: scaleY(1); } from { opacity: 1; transform: translateY(0); }
to { opacity: .2; clip-path: inset(0 0 100% 0); transform: scaleY(.96); } to { opacity: 0; transform: translateY(var(--menu-entry-offset, -6px)); }
} }
.header-utilities .menu-dropdown { .header-utilities .menu-dropdown {
@@ -4771,6 +4768,9 @@ input[type="checkbox"] {
min-width: 0; min-width: 0;
} }
.history-header { flex-wrap: wrap; gap: 10px 16px; }
.history-header > h2 { flex: 0 0 auto; white-space: nowrap; }
.history-retention-select { .history-retention-select {
min-width: 150px; min-width: 150px;
} }
@@ -5757,3 +5757,8 @@ input[type="checkbox"] {
color: #b9c2d0; color: #b9c2d0;
font-size: 12px; 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; }