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

Unexpected CSS margins added to container blocks #34716

Open
iandunn opened this issue Sep 9, 2021 · 2 comments
Open

Unexpected CSS margins added to container blocks #34716

iandunn opened this issue Sep 9, 2021 · 2 comments
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended

Comments

@iandunn
Copy link
Member

iandunn commented Sep 9, 2021

Description

As of #33812, spacing gaps are automatically applied to FSE themes. That can cause unexpected results for theme authors in some situations.

we don't have answers for all the use cases yet...
I'd love to learn mode about the use-cases to be able to come up with the best abstractions that solve this

I thought it'd be helpful to have an issue where we can post those use cases. Please add comments here when you encounter one.

Step-by-step reproduction instructions

Both of these are with the default 24px gap, rather than defining one in theme.json.


.site-header is given a margin-top because .skip-link precedes it:

<div class="wp-site-blocks">
	<a class="skip-link screen-reader-text" href="#wp--skip-link--target">Skip to content</a>

	<header class="wp-container-613a423080be0 wp-block-group site-header">

I expected it to have none, since it's the site header and the preceding element is visually hidden. maybe fix by adding a not(.screen-reader-text) selector. that wouldn't catch everything, but it might get most.


More broadly, child elements of .site-header and .site-footer are given margin-top, but I'd expect only post content and the sidebar to be affected. I don't really see a logical relationship in those areas like there is with elements inside post content.

Maybe in general-purpose themes everything should be affected, but not in a custom theme where the header/footer are locked.

( previously mentioned by @chthonic-ds )

Screenshots, screen recording, code snippet

No response

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@Sandstromer
Copy link

Would it be possible to have an option on all blocks that would allow the block gap to be toggled off in those instances where it is not required?

If that was an option, templates and parts could define when a particular block would have the block gap off, e.g. something like "hasBlockGap":false

<!-- wp:group {"tagName":"header","className":"site-header","hasBlockGap":false} -->
<header class="wp-block-group site-header">

@youknowriad
Copy link
Contributor

I expected it to have none, since it's the site header and the preceding element is visually hidden. maybe fix by adding a not(.screen-reader-text) selector. that wouldn't catch everything, but it might get most.

Good point on this one, this one is more like a bug, maybe we can render the "skip-link" outside the "wp-site-blocks"?

@annezazu annezazu added [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended CSS Styling Related to editor and front end styles, CSS-specific issues. labels Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants