stash
stash copied to clipboard
fix: close Lightbox overlay on browser back button press
The Image View overlay (Lightbox) did not close when the browser back button was pressed, causing the overlay to persist over the wrong page or show an empty state.
- Add popstate event listener to close lightbox on browser navigation
- Push history entry when lightbox opens so back closes it without navigating away from the current page
- Use ref for onClose callback to avoid stale closures
Related Issue
Fixes #1940
Testing
- Go to 'Galleries'
- Click on any gallery
- Click on any image in the gallery to open it with Image View overlay UI
- Click the "Back" button in the web browser
- Lighbox succesfully closes and, it doesn't stay open.
Checklist
- [x] I have read and understood the Contributing document.
- [x] I have read and understood the AI Usage Policy document.
- [ ] I have made corresponding changes to the documentation (if applicable).
AI Usage Disclosure
- [x] I have used AI tools to assist with this pull request, and I have disclosed the tools and how I used them below.
Mimo v2.5 LLM and Coderabbit used to review the code.