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

Table block: Bottom margin pushes the caption down #68217

Open
3 of 6 tasks
andersnoren opened this issue Dec 21, 2024 · 2 comments · May be fixed by #68281
Open
3 of 6 tasks

Table block: Bottom margin pushes the caption down #68217

andersnoren opened this issue Dec 21, 2024 · 2 comments · May be fixed by #68281
Assignees
Labels
[Block] Table Affects the Table Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@andersnoren
Copy link

Description

When you set a margin on the table block in theme.json, the margin is applied to the table element inside of the figure element. If you include a table caption, the figcaption is included after the table element, which means that the bottom margin applied to the block will be added between the table and the figcaption, instead of beneath the block as a whole.

If you apply a custom vertical margin to the table block inside of the editor, that margin is added to the figure element. That means that you can't overwrite the theme.json table margin on a specific table block.

Step-by-step reproduction instructions

  1. Create a new post.
  2. Insert a table block, and give it a figcaption.
  3. Note the theme.json bottom margin for the core/table block being applied on the table element, pushing down the caption.
  4. Add a vertical margin to the table block inside of the editor. It will be applied to the figure element, which means that the table block now has a vertical margin on the table element, set in theme.json, and a vertical margin set on the figure element, set with the custom margins in the editor.

Screenshots, screen recording, code snippet

Block markup for a table block with 128px in custom vertical margin.

<!-- wp:table {"className":"is-style-regular","style":{"spacing":{"margin":{"top":"128px","bottom":"128px"}}}} -->
<figure class="wp-block-table is-style-regular" style="margin-top:128px;margin-bottom:128px"><table class="has-fixed-layout"><thead><tr><th>Table Header</th><th>Table Header</th></tr></thead><tbody><tr><td>Table Cell</td><td>Table Cell</td></tr><tr><td>Table Cell</td><td>Table Cell</td></tr></tbody><tfoot><tr><td>Table Footer Cell</td><td>Table Footer Cell</td></tr></tfoot></table><figcaption class="wp-element-caption">This is the table caption.</figcaption></figure>
<!-- /wp:table -->

Screenshot of a table block given 128px vertical margin in theme.json (table element), and 128px custom vertical margin on this specific table block (figure element).
Image

Environment info

WordPress 6.7.1
With and without Gutenberg 19.9.0 active

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@andersnoren andersnoren added the [Type] Bug An existing feature does not function as intended label Dec 21, 2024
@t-hamano t-hamano added the [Block] Table Affects the Table Block label Dec 22, 2024
@Infinite-Null
Copy link
Contributor

Hi @andersnoren,

Thank you for bringing this up. I was successfully able to reproduce the issue. My theme.json is:

{
	"$schema": "../../../schemas/json/theme.json",
	"version": 3,
	"styles": {
	  "color": {
		"background": "white"
	  },
	  "blocks": {
		"core/table": {
		  "spacing": {
			"margin": {
			  "top": "128px",
			  "bottom": "128px"
			}
		  }
		}
	  }
	}
  }

Screencast:

Screen.Recording.2024-12-22.at.6.28.54.PM.mov

I’ll work on a solution for this issue and open a draft PR shortly.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Dec 25, 2024
@Infinite-Null
Copy link
Contributor

Hi @andersnoren and @t-hamano,

I’ve created a PR with the proposed solution. I’d appreciate it if you could test and review it.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Table Affects the Table Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants