Skip to content

Nmc/5325 file list shows empty when switching between grid and list view#478

Open
suet-kei-chan wants to merge 2 commits into
stable32from
nmc/5325-file-list-shows-empty-when-switching-between-grid-and-list-view
Open

Nmc/5325 file list shows empty when switching between grid and list view#478
suet-kei-chan wants to merge 2 commits into
stable32from
nmc/5325-file-list-shows-empty-when-switching-between-grid-and-list-view

Conversation

@suet-kei-chan
Copy link
Copy Markdown

@suet-kei-chan suet-kei-chan commented May 18, 2026

A new function setupGridViewScrollFix() is added which fixes the blank screen issue when switching between list and grid view with many files.

Root cause:
.files-list is both the scroll container and the element that gets the files-list--grid class toggled. When the view switches, the virtual scroll doesn't recalculate which rows to render for the new item sizes, resulting in a blank screen until the user manually scrolls.

Fix:

  • A MutationObserver watches document.body for .files-list to appear in the DOM
  • Once found, a second MutationObserver watches .files-list for class changes (files-list--grid being added/removed)
  • On each view switch, a synthetic scroll event is dispatched on .files-list via setTimeout(0). This lets the CSS fully reflow first, then triggers the virtual scroll to recalculate visible rows at the user's current scroll position without resetting it

The .files-list element is the actual scroll container (confirmed via
DOM inspection — scrollTop > 0 on .files-list when scrolled, not on
window or #app-content-vue).

When switching between list and grid view, the virtual scroll does not
automatically recalculate visible rows for the new item sizes, leaving
a blank screen until the user manually scrolls.

Fix: watch for files-list--grid class changes on .files-list via
MutationObserver, then dispatch a synthetic scroll event on the same
element via setTimeout so CSS has fully reflowed before the event fires.
This triggers the virtual scroll to recalculate visible rows at the
current position without changing the user's scroll position.
@suet-kei-chan suet-kei-chan self-assigned this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant