Repository navigation
Description
1. What is not working as documented?
In web browser, if I scroll down some steps (as the page will load more when scrolled to bottom, you have to make it load) and open a folder in folders view, then click back to return to folders view, it will try to restore to previous position, but it won't automatically load more folders when reaching bottom, so the position is not correct. You always stop at initial loaded folders, which makes it hard to use if you are trying finding some old photos, you have to manually scroll to trigger auto loading to reach previous position.
2. How can we reproduce it?
Steps to reproduce the behavior:
- Go to 'folders' view
- Scroll down to bottom to trigger auto loading more folders
- Click a folder that is loaded with auto loading, not a initial loaded folder
- Click back button of browser
- It will try to restore previous scroll position, but it won't trigger auto loading when reaches bottom, so it always stops at initial loaded folders.
3. What behavior do you expect?
It saves previously loaded folders and restore to the position correctly, or while restoring the position it automatically triggers reloading and restore the position correctly.
4. What could be the cause of your problem?
I can see it did 1 auto loading when reached to bottom on restoring position, but then it stops to restoring position, maybe we need some way to continue loading and scrolling until reaches the correct position.
5. Can you provide us with example files for testing, error logs, or screenshots?
6. Which software versions do you use?
(a) PhotoPrism Architecture & Build Number: 250707-d28b3101e-Linux-x86_64
(b) Database Type & Version: mariadb from 12.0.2-MariaDB, client 15.2 for Linux (x86_64) using readline 5.1
(c) Operating System Types & Versions: Arch Linux 6.16.4-arch1-1
(d) Browser Types & Versions: Both Firefox and Chrome on macOS can reproduce this.
(e) Ad Blockers, Browser Plugins, and/or Firewall Software? This can be reproduced in Private window.
7. On what kind of device is PhotoPrism installed?
This is especially important if you are reporting a performance, import, or indexing issue. You can skip this if you're reporting a problem you found in our public demo, or if it's a completely unrelated issue, such as incorrect page layout.
(a) Device / Processor Type: Ryzen 3 PRO 5350G
(b) Physical Memory & Swap Space in GB: 32GB/32GB
(c) Storage Type: HDD, SSD, RAID, USB, Network Storage,...: 4-HDD RAID10
(d) Anything else that might be helpful to know? None
8. Do you use a Reverse Proxy, Firewall, VPN, or CDN?
No, I reproduced this in my home and I directly connected to PhotoPrism's HTTP port.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsRelease 🌈
Activity
graciousgrey commentedon Sep 15, 2025
Thanks for the report and the clear reproduction hints!
What’s happening
– The scroll position is remembered and a restore is triggered when you navigate back.
– However, the restore callback currently fires only once right after mount. At that moment, the album/folder item near the bottom often isn’t in the DOM yet because the list is still loading in batches (infinite scroll). As a result, the browser can’t scroll to a target that hasn’t been rendered, so you end up at the top again.
Why this is expected with our current loading strategy
– Albums and Folders views use progressive loading with virtualization / placeholders to keep memory and rendering costs under control. See Developer Guide
– On back-navigation we do restore, but we don’t retry once more items arrive, so the first (and only) attempt can miss when the target item is far down the list.
Two ways forward (trade-offs)
“Wait longer” approach
– Delay the single restore callback in hopes that enough items have loaded.
– Doesn’t reliably fix slow connections or very large lists; still races.
“Load enough & retry” approach (recommended)
– Persist both the last clicked item’s UID and its index (position) when navigating into an item.
– On return:
a) Increase the initial batch so the saved index is included, e.g. request count = max(default, savedIndex + smallBuffer).
b) Re-attempt restore whenever a batch finishes until either:
• the saved index is loaded (then scroll to the item/approximate offset), or
• a sane cap is reached.
– Because our API supports count/offset, we can request a larger first page or jump via offset when needed
– With pseudo-virtualization in place, fetching metadata models for N items is cheap; thumbs render only when visible.
Implementation sketch
– Persist on click:
history.state = { uid, index, scrollY }– On the Albums/Folders page
• Read saved { uid, index } on mounted.
• Compute
initialCount = Math.max(defaultCount, index + buffer).• Trigger first load with initialCount (or offset/index-aware query).
• After each “batch appended” event, call tryRestore():
• Stop retrying once restored or a hard limit is reached.
Notes / limits
– “Load all” in one go is risky (time/memory) on very large libraries; better to load “enough” based on index plus a small buffer, then retry restore as batches arrive.
– We should also reset any accumulated back-navigation offset after a successful restore (see #2627) to avoid growing first-load sizes across sessions.
If there are no objections, we’ll proceed with option (2): save UID+index on navigation, increase the initial batch size based on index, and retry scrolling after each appended batch until the target exists. This should make back-navigation deterministic even when the destination is far down the list and the connection is slow.
Links for context
UX: Improve window scroll position restoration when navigating #5211
lastzero commentedon Oct 3, 2025
@AlynxZhou These changes should resolve the issue. Let us know if it works!
I'll start a new preview build soon so you can test it:
Frontend: Update deps in package.json and package-lock.json #5211
23 remaining items
AlynxZhou commentedon Oct 9, 2025
I changed both view.js and notify.js, still not work, it loads once more but not scrolling down.
Frontend: Update deps in package.json and package-lock.json #5211
Frontend: Restore scroll state on back navigation #5211
lastzero commentedon Oct 9, 2025
It turned out that the way the back navigation was detected didn't work with the current browsers and Vue version anymore, so I introduced a new, more advanced detection method in our view helper. You are welcome to test it and provide feedback!
Frontend: Remove unnecessary saveWindowScrollPos() calls #5211
[-]UX: Restore scroll position with auto loaded more folders when back from folder to all folders[/-][+]UX: Restoring the scroll state on back navigation is broken[/+]AlynxZhou commentedon Oct 10, 2025
This times it works as intended. We could close this and I am waiting for the next stable release.
AlynxZhou commentedon Oct 10, 2025
I am very appreciate for your work!