viewer icon indicating copy to clipboard operation
viewer copied to clipboard

Fix taking sidebar position in fullscreen mode

Open ShGKme opened this issue 2 years ago • 5 comments

🐞 Resolves

  • Kind of regression of https://github.com/nextcloud/viewer/pull/1640

Steps to reproduce:

  1. Open files
  2. Open a file sidebar
  3. On this moment Viewer handle sidebar state change and updates the size
  4. Open a file
  5. Sidebar goes full-screen mode
  6. Viewer is opened (with the old size)
  7. 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

Old description

A bug

How Viewer react on sidebar opening now in Files:

  1. Viewer is open, sidebar is closed: State-1
  2. Click "Open Sidebar"
  3. Sidebar is opened in the default layout State-2
    • File info is loading
    • Viewer takes it's position to set its width
  4. Loading is finished. Sidebar goes fullscreen. But viewer still use old position for width State-3
  5. 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

State-4

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:

  1. Always use Sidebar in the fullscreen mode with Viewer. Then we can just always use width.
  2. Change Sidebar, make it Fullscreen immediately, not after all data is loaded
  3. Add a ghost element directly in DOM inside Sidebar and use ResizeObserver
  4. Partially revert https://github.com/nextcloud/viewer/pull/1640 and keep Files accurate having overlap in other apps without fullscreen sidebar.

ShGKme avatar Jun 08 '23 21:06 ShGKme

Rebased onto master + compiled in prod mode

ShGKme avatar Jun 08 '23 21:06 ShGKme

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.

juliusknorr avatar Jul 13 '23 20:07 juliusknorr

PR is updated after https://github.com/nextcloud/server/pull/39378

ShGKme avatar Jul 28 '23 13:07 ShGKme

@juliushaertl @skjnldsv @artonge Sorry for mentions :) I'll check Cypress tests if everything looks fine by code/solution.

ShGKme avatar Aug 08 '23 17:08 ShGKme

Please don't forget to set the milestone when opening a PR :smiley:

blizzz avatar Nov 23 '23 12:11 blizzz