Header shifts to the right when you open image gallery

AI-generated summary

The discussion addresses a UI issue where the header shifts slightly to the right when opening an image gallery in full screen on Chrome. rlb reports the issue, and Johani explains it’s caused by the browser scrollbar being hidden during the lightbox display, which affects layout due to differing scrollbar widths across platforms. Johani clarifies that while Magnific-popup compensates for scrollbar width in content, the header’s fixed CSS positioning prevents proper alignment. Potential fixes include CSS compensation, maintaining a fork, or duplicating scrollbar logic—none are ideal. Johani concludes that the fix is too involved for the minor visual issue, and the behavior should be left as-is for now. rlb acknowledges the explanation.

Hi,

When you want to see a big image in full screen, header is shifted by a few pixels to the right of the screen.

Edit: I’m on Chrome.

3 Likes

This occurs because we hide the browser scrollbar when you open a lightbox.

Given that the scrollbar width is different on different browsers on different platforms, it makes sense to leave this as is for now since the visual inconsistency is not very noticeable unless you’re looking directly at it.

6 Likes

Yes, that’s what I suspected. But why the rest of the content is not affected by this?

2 Likes

Well, that’s a good question.

The answer is because Magnific-popup - the dependency the handles galleries in Discourse - actually does what I described above. It checks the width of the scrollbar in the current browser and then compensates with inline margins.

This works well for the content of the page, but the fact that the header in Discourse is positioned with CSS - absolute and then fixed when you scroll down - means that things don’t come out right for it. So, you get the issue you described.

So, the options are:

1- manually compensate with CSS
this doesn’t work because of different scrollbar widths.

2- maintain a fork of Magnific-popup that fixes this
this is out of the question.

3- duplicate the scrollbar width calculation in Discourse
this is way too much code for a simple visual inconsistency.

4- leave this as is because how involved a fix would be V.S the benefits of adding it.

I still think #4 is the way to go here, at least for now.

7 Likes

Ok, thank you for the explanations. :slightly_smiling_face:

2 Likes