Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client): sticky header leaves 1px gap on top #11644

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

OnkarRuikar
Copy link
Contributor

@OnkarRuikar OnkarRuikar commented Aug 17, 2024

Summary

Depending on the zoom level, the sticky-header-container leaves a 1px gap on the top.

Problem

Refer to the following video:

stiky_header_1px_gap.mp4

Note that the viewport's top border has white dots.

Make sure you have the dark theme on. If you can not reproduce it, change the browser zoom level slightly and scroll so that some text reaches the top border of the viewport. Keep changing zoom till you see the gap. I can reproduce this in Firefox and Chrome.

Solution

This is due to some zoom levels producing fractions in the header dimensions, so a 1px gap remains after rounding. Pulling the header 1px up by using top: -1px should cover the gap.


How did you test this change?

In a browser before and after the fix.

@OnkarRuikar OnkarRuikar requested a review from a team as a code owner August 17, 2024 06:32
@github-actions github-actions bot added the idle label Sep 16, 2024
@caugner
Copy link
Contributor

caugner commented Sep 27, 2024

I can reproduce this in Firefox and Chrome.

I was able to reproduce in BrowserStack Live at 1920x970 on Windows 11 with Chrome 128 consistently at zoom level 75% (but not at 67% / 80% / 90%), and with Firefox 130 once at zoom level 67% (but not at other zoom levels).

The header.top-navigation element nevertheless has a clientTop: 0, so I'm wondering if this is a browser bug?

client/src/app.scss Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the idle label Sep 27, 2024
OnkarRuikar and others added 2 commits September 28, 2024 08:37
Co-authored-by: Claas Augner <495429+caugner@users.noreply.github.com>
@@ -355,7 +355,7 @@ sup.new {

.sticky-header-container {
position: sticky;
top: 0;
top: -0.1px;
Copy link
Contributor Author

@OnkarRuikar OnkarRuikar Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
top: -0.1px;
top: -1px;

The -0.1px doesn't work on Firefox developer 131.0b9 (64-bit) at 300% zoom on Linux Mint 22 x86_64:

zoomIssue.mp4

It's a rounding error, so it is better to use a complete pixel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants