-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Sticky Position: Fix top position while logged in on mobile #47665
Sticky Position: Fix top position while logged in on mobile #47665
Conversation
Just pinging a few people involved with the sticky position support for feedback on the approach in this PR. Happy for any other ideas if this looks off / if there are concerns about adding to the Group block's CSS! CC: @jameskoster @richtabor @apeatling @tellthemachines @jasmussen |
Size Change: +340 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working well for me, and I'm not against adding the semantic classname for consistency with the layout support, but I'm wondering if it might not be more future proof -considering we may have other position types with similar problems and we'll almost certainly want to apply positioning to more block types -
to instead define a --wp-admin--admin-bar--offset
(or something) variable, setting its value to --wp-admin--admin-bar--height
only above a certain breakpoint, and put it perhaps in the common file, and then we can use that new variable in the position logic instead of --wp-admin--admin-bar--height
?
Oh, I like that idea, that would better contain the logic if we assign the offset there and reference the separate variable like you mention. I'll have a play and see how it looks... |
I've pushed an update (6f72dd0) that does the following:
Overall, I think that's a nice improvement over including the CSS in the group block, Happy to make any further changes, though, I don't feel very strongly about the choices I just made 😄 |
Flaky tests detected in 52bd2b3. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4071771777
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! In my previous comment I was thinking that by setting a new custom property we could avoid adding the classname altogether for now (I'm fine with adding it, but at this point in time it's just more stuff to backport). We don't really need to scope the property because it's not being used anywhere else (and it would be fine if it where, because its behaviour just reproduces the admin bar). But I'm not too concerned either way, and people do tend to appreciate semantic classnames 😄
I'm not too concerned, either, but @carolinan made a good point that folks do appreciate semantic classnames, and if it makes it easier for themes to override the rules if they want to do their own thing, then I think I lean slightly toward adding them in. Let's see if anyone has strong opinions on it overnight 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think renaming the var and moving the CSS was a good call.
In my testing the PR works well as the gap on smaller widths is removed.
I think we should keep the class name, unless we think that new settings means that we will need it to be even more specific in the future. Yes people often want to add bottom borders, shadows, animations or reduce an items height etc when it is stickied. |
Thanks for confirming @carolinan (and the reviews, both of you!) I'm wrapping up for the day now, if there are no objections from anyone else overnight, I'll merge this in tomorrow morning my time 🙂 |
@ntsekouras @Mamaduka is this okay to be cherry picked in for 6.2? (It's a bug fix for a feature I'm in the process of backporting, so it'd be great for this one to make it in if we can). Just thought I'd confirm that adding the |
@andrewserong, sure 👍 |
* Sticky Position: Fix top position while logged in on mobile * Clarify comment * Ensure classname is output in editor, too * Fix linting issue * Move CSS to common.scss, decouple from Group block * Use same selector inside the media query Co-authored-by: Carolina Nymark <hi@themesbycarolina.com>
I just cherry-picked this PR to the release/15.1 branch to get it included in the next release: a817302 |
What?
Fixes #47566, part of #47043, following on from #46142
Fix the issue where the top position for sticky positioned group blocks is incorrect while logged in on mobile. This is achieved by adding a classname to the position markup, and a CSS rule to the common CSS to reset the admin height CSS variable within the scope of the sticky position classname.
Kudos @carolinan for opening the issue and the suggestion for the fix.
Why?
As reported in #47566, the logged in CSS for the admin bar has it absolutely positioned to the top of the page within the mobile breakpoint, rather than fixed to the top of the page. For viewports larger than
600px
the existing calculation to offset the area of the admin bar works correctly, however for viewports smaller than600px
the sticky position output resulted in the sticky block being too low (not flush with the top of the page).How?
is-position-sticky
).Testing Instructions
A question for the reviewer: is there a better place to put the override CSS? Does the solution here seem reasonable enough for the time-being? I'd love it if there was a way to avoid introducing this media query, but I couldn't think of an alternative 🤔
Screenshots or screencast