Fix taking sidebar position in fullscreen mode
🐞 Resolves
- Kind of regression of https://github.com/nextcloud/viewer/pull/1640
Steps to reproduce:
- Open files
- Open a file sidebar
- On this moment Viewer handle sidebar state change and updates the size
- Open a file
- Sidebar goes full-screen mode
- Viewer is opened (with the old size)
- There is a gap
🖼️ Changes
Take the sidebar position in beforeOpen
Before
https://github.com/nextcloud/viewer/assets/25978914/3b149a97-aeeb-4dbd-bc04-c922c5798489
After
https://github.com/nextcloud/viewer/assets/25978914/84654845-7981-4f6c-8a09-4a8e209617e1
A bug
How Viewer react on sidebar opening now in Files:
- Viewer is open, sidebar is closed:
- Click "Open Sidebar"
- Sidebar is opened in the default layout
- File info is loading
- Viewer takes it's position to set its width
- Loading is finished. Sidebar goes fullscreen. But viewer still use old position for width
- There is a gap between Viewer and Sidebar
Exactly the same happens when Viewer is opened having Sidebar already opened.
It wasn't a problem before https://github.com/nextcloud/viewer/pull/1640 because incorrect width early was correct for fullscreen mode.
Expected behavior
No gap
Solution in this PR
Retake Sidebar's position when file opening (including transition animation) is finished.
Drawbacks
Because of sub-loading and 100ms transition on width, for a short time there is a gap anyway and animation if it's disappearing...
https://github.com/nextcloud/viewer/assets/25978914/2feb7e04-6ace-4814-ae3c-3832a50d9e6c
Alternative solutions
Alternative solutions could be:
- Always use Sidebar in the fullscreen mode with Viewer. Then we can just always use width.
- Change Sidebar, make it Fullscreen immediately, not after all data is loaded
- Add a ghost element directly in DOM inside Sidebar and use
ResizeObserver - Partially revert https://github.com/nextcloud/viewer/pull/1640 and keep Files accurate having overlap in other apps without fullscreen sidebar.
Rebased onto master + compiled in prod mode
Just noticed this existed after working on an alternative approach at https://github.com/nextcloud/server/pull/39378, but it is basically alternative 1 you considered. Would appreciate input on that one as it seems to have the same effect without the mentioned drawback from above.
PR is updated after https://github.com/nextcloud/server/pull/39378
@juliushaertl @skjnldsv @artonge Sorry for mentions :) I'll check Cypress tests if everything looks fine by code/solution.
Please don't forget to set the milestone when opening a PR :smiley: