Skip to content

Commit c09027e

Browse files
ozgesolidkeyclaude
andcommitted
Fix minimap preview sticky behavior and recent files z-index
Minimap preview: - Preview locks in place when mouse enters it (no repositioning) - Requires 15px vertical movement before updating position - 300ms delay before hiding to allow reaching the preview - Can now scroll horizontally inside without it escaping Recent files dropdown: - Fixed z-index: position:fixed with z-index 1001 above toolbar overflow - Dynamically positioned below the Open File button - Chevron click properly prevents file dialog from opening Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1090886 commit c09027e

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

src/renderer/renderer.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,24 +3294,29 @@ function handleMinimapClick(event: MouseEvent): void {
32943294
let minimapPreviewTimer: ReturnType<typeof setTimeout> | null = null;
32953295
let minimapPreviewHideTimer: ReturnType<typeof setTimeout> | null = null;
32963296
let minimapPreviewLine = -1;
3297+
let minimapPreviewLastY = -1; // Last Y that triggered a preview render
3298+
let minimapPreviewLocked = false; // True when user is interacting with preview
32973299

32983300
function isMinimapPreviewEnabled(): boolean {
32993301
return userSettings.minimapPreview;
33003302
}
33013303

33023304
function setupMinimapPreviewListeners(previewEl: HTMLElement): void {
33033305
previewEl.addEventListener('mouseenter', () => {
3304-
// Cancel any pending hide when mouse enters preview
3306+
// Lock preview in place while user is inside it
3307+
minimapPreviewLocked = true;
33053308
if (minimapPreviewHideTimer) { clearTimeout(minimapPreviewHideTimer); minimapPreviewHideTimer = null; }
33063309
});
33073310
previewEl.addEventListener('mouseleave', () => {
3308-
// Hide after a short delay when mouse leaves preview
3309-
minimapPreviewHideTimer = setTimeout(() => hideMinimapPreviewNow(), 200);
3311+
minimapPreviewLocked = false;
3312+
minimapPreviewHideTimer = setTimeout(() => hideMinimapPreviewNow(), 300);
33103313
});
33113314
}
33123315

33133316
function handleMinimapHover(event: MouseEvent): void {
33143317
if (!minimapElement || isDraggingMinimap || !isMinimapPreviewEnabled()) return;
3318+
// Don't reposition if the user is interacting with the preview
3319+
if (minimapPreviewLocked) return;
33153320
// Cancel any pending hide
33163321
if (minimapPreviewHideTimer) { clearTimeout(minimapPreviewHideTimer); minimapPreviewHideTimer = null; }
33173322

@@ -3321,9 +3326,13 @@ function handleMinimapHover(event: MouseEvent): void {
33213326
const totalLines = getTotalLines();
33223327
if (totalLines === 0) return;
33233328

3329+
// Require at least 15px vertical movement before repositioning the preview
3330+
if (minimapPreviewLastY >= 0 && Math.abs(hoverY - minimapPreviewLastY) < 15) return;
3331+
33243332
const targetLine = Math.floor((hoverY / minimapHeight) * totalLines);
33253333
if (targetLine === minimapPreviewLine) return;
33263334
minimapPreviewLine = targetLine;
3335+
minimapPreviewLastY = hoverY;
33273336

33283337
if (minimapPreviewTimer) clearTimeout(minimapPreviewTimer);
33293338
minimapPreviewTimer = setTimeout(async () => {
@@ -3364,6 +3373,8 @@ function hideMinimapPreviewNow(): void {
33643373
if (minimapPreviewTimer) { clearTimeout(minimapPreviewTimer); minimapPreviewTimer = null; }
33653374
if (minimapPreviewHideTimer) { clearTimeout(minimapPreviewHideTimer); minimapPreviewHideTimer = null; }
33663375
minimapPreviewLine = -1;
3376+
minimapPreviewLastY = -1;
3377+
minimapPreviewLocked = false;
33673378
const preview = document.getElementById('minimap-preview');
33683379
if (preview) preview.classList.add('hidden');
33693380
}
@@ -4192,6 +4203,11 @@ async function toggleRecentFilesPopup(): Promise<void> {
41924203
}
41934204

41944205
popup.innerHTML = html;
4206+
4207+
// Position below the Open File button using fixed positioning
4208+
const btnRect = elements.btnOpenFile.getBoundingClientRect();
4209+
popup.style.top = `${btnRect.bottom + 4}px`;
4210+
popup.style.left = `${btnRect.left}px`;
41954211
popup.classList.remove('hidden');
41964212

41974213
// Wire up clicks
@@ -12704,7 +12720,11 @@ function init(): void {
1270412720
elements.logo.style.cursor = 'pointer';
1270512721

1270612722
// File operations
12707-
elements.btnOpenFile.addEventListener('click', openFile);
12723+
elements.btnOpenFile.addEventListener('click', (e) => {
12724+
// Don't open file dialog if the recent files chevron was clicked
12725+
if ((e.target as HTMLElement).id === 'btn-recent-files') return;
12726+
openFile();
12727+
});
1270812728
elements.btnRecentFiles.addEventListener('click', (e) => {
1270912729
e.stopPropagation();
1271012730
e.preventDefault();

src/renderer/styles.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,7 @@ body.platform-darwin .titlebar {
299299
.open-file-chevron:hover { opacity: 1; }
300300

301301
.recent-files-popup {
302-
position: absolute;
303-
top: 100%;
304-
left: 0;
302+
position: fixed;
305303
background-color: var(--bg-secondary);
306304
border: 1px solid var(--border-color);
307305
border-radius: 4px;
@@ -312,7 +310,6 @@ body.platform-darwin .titlebar {
312310
max-height: 400px;
313311
display: flex;
314312
flex-direction: column;
315-
margin-top: 4px;
316313
}
317314
.recent-files-popup.hidden { display: none; }
318315

0 commit comments

Comments
 (0)