-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Accordion Item: Don't use grid layout #73501
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
Conversation
|
Size Change: -206 B (-0.01%) Total Size: 2.54 MB
ℹ️ View Unchanged
|
da44fa7 to
f020718
Compare
f020718 to
7de647c
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 7de647c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19606029190
|
mikachan
left a comment
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.
Great CSS refactor 👏 I'm also not sure why we were using display: grid here. Either way, this is testing well. Thank you!
|
I'm not sure if that actually was the reason for using grid but I have a hunch that it might be because it's a CSS hack which allows you to animate between 0 and an unknown height in CSS which is otherwise not possible. That trick is often used in accordions to create that smooth opening / closing animation. But again I have no idea if that is actually the reason why it was used here and it seems like even if it was it no longer does that so we should be good to remove it |
Ah, after further investigation, I discovered that the current behavior without animation is an unintended regression 😅 The Accordion block was originally intended to have animations. I believe the animations were disabled in #71866 which added I think there are two approaches:
Personally, I prefer the latter approach, as very few core blocks have animations by default. Perhaps we could use the Web Animations API instead of Grid Layout. What do you think? |
| grid-template-rows: max-content 0fr; | ||
|
|
||
| &.is-open { | ||
| grid-template-rows: max-content 1fr; |
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.
@t-hamano I think the easiest fix (for 6.9) is to simply replace any instanced of 1fr with minmax(0, 1fr).
As described here that resolves the grid "blowout" issue: https://css-tricks.com/preventing-a-grid-blowout/
That way this is all you need to do update to fix the actual bug described in the linked issue.
However big picture I think moving away from grid and not restoring the animation using this hack is the right call
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.
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.
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.
- Don't use a grid layout (the approach taken in this PR)
- Add box-sizing:border-box
If both approaches solve the overflow problem, wouldn't the former approach be the best? Ultimately, we're aiming to avoid using a grid.
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.
Yeah 👍 Makes sense :)
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.
It's a shame the animation didn't work as intended, but let's try a different approach as a follow-up.
Co-authored-by: t-hamano <[email protected]> Co-authored-by: mikachan <[email protected]> Co-authored-by: fabiankaegy <[email protected]> Co-authored-by: justintadlock <[email protected]>
|
I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: 516024c |
Changes can be found at https://github.com/WordPress/gutenberg/commits/wp/6.9/. * [Fix isNewLink value with entity binding (#73368)](WordPress/gutenberg#73368) * [Unit testing: Allow Composer to auto-detect PHP version (#73358)](WordPress/gutenberg#73358) * [Move the Edit Navigation button to the last item in the block toolbar to ensure that the styling is consistent and simple (#73436)](WordPress/gutenberg#73436) * [Block Support: Change block visibility support key (#73432)](WordPress/gutenberg#73432) * [Accordion: add box-sizing:border-box rule (#73507)](WordPress/gutenberg#73507) * [Accordion Block: Trigger panel opening from URL hash or anchor link (#73357)](WordPress/gutenberg#73357) * [iAPI: Backport of "Return a deep-clone object from `getServerState` and `getServerContext` functions" (#73514)](WordPress/gutenberg#73514) * [Reuse wp_script_attributes filter for adding data-wp-router-options attribute to script module (#72489) (#73512)](WordPress/gutenberg#73512) * [Accordion Item: Don't use grid layout (#73501)](WordPress/gutenberg#73501) * [Drag and drop: remove grab cursor for multi-selection (#73521)](WordPress/gutenberg#73521) * [Math block: fix accessibility (#73508)](WordPress/gutenberg#73508) * [iAPI: Fix using `getServerContext` in derived state getters (#73518) (#73531)](WordPress/gutenberg#73531) * [Drag: hide block tools popovers (#73539)](WordPress/gutenberg#73539) Developed in #10549. See https://make.wordpress.org/core/handbook/about/release-cycle/block-editor-release-process-for-major-releases/#package-updates-and-core-patches. Props priethor. See #64301. git-svn-id: https://develop.svn.wordpress.org/branches/6.9@61304 602fd350-edb4-49c9-b593-d223f7449a82
Changes can be found at https://github.com/WordPress/gutenberg/commits/wp/6.9/. * [Fix isNewLink value with entity binding (#73368)](WordPress/gutenberg#73368) * [Unit testing: Allow Composer to auto-detect PHP version (#73358)](WordPress/gutenberg#73358) * [Move the Edit Navigation button to the last item in the block toolbar to ensure that the styling is consistent and simple (#73436)](WordPress/gutenberg#73436) * [Block Support: Change block visibility support key (#73432)](WordPress/gutenberg#73432) * [Accordion: add box-sizing:border-box rule (#73507)](WordPress/gutenberg#73507) * [Accordion Block: Trigger panel opening from URL hash or anchor link (#73357)](WordPress/gutenberg#73357) * [iAPI: Backport of "Return a deep-clone object from `getServerState` and `getServerContext` functions" (#73514)](WordPress/gutenberg#73514) * [Reuse wp_script_attributes filter for adding data-wp-router-options attribute to script module (#72489) (#73512)](WordPress/gutenberg#73512) * [Accordion Item: Don't use grid layout (#73501)](WordPress/gutenberg#73501) * [Drag and drop: remove grab cursor for multi-selection (#73521)](WordPress/gutenberg#73521) * [Math block: fix accessibility (#73508)](WordPress/gutenberg#73508) * [iAPI: Fix using `getServerContext` in derived state getters (#73518) (#73531)](WordPress/gutenberg#73531) * [Drag: hide block tools popovers (#73539)](WordPress/gutenberg#73539) Developed in WordPress/wordpress-develop#10549. See https://make.wordpress.org/core/handbook/about/release-cycle/block-editor-release-process-for-major-releases/#package-updates-and-core-patches. Props priethor. See #64301. Built from https://develop.svn.wordpress.org/branches/6.9@61304 git-svn-id: http://core.svn.wordpress.org/branches/6.9@60616 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Fixes #73455
What?
This PR removes unnecessary grid layout from the Accordion Item block.
This removes several unnecessary CSS hacks, as a result, resolving the issue reported in #73455.
Why? How?
Perhaps this grid CSS was originally intended to be used to visually hide the accordion panel. However, since the panel is visually hidden here depending on the state, the grid CSS itself is not necessary.
Because the Accordion Item is no longer grid layout, its child elements are guaranteed to be 100% width by default. Therefore, the
min-widthrequired for the classic theme is no longer necessary.As a result, overflow issues when padding or borders are added to panels are resolved.
Testing Instructions
Testing for Block Gap
Testing for Classic Theme
min-widthto make them wider, but now they work correctly without thismin-width.Screenshots or screencast
Before
After