-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Layout: Fix toggling off inner blocks content width setting for legacy markup #43888
Layout: Fix toggling off inner blocks content width setting for legacy markup #43888
Conversation
Size Change: +2 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
@@ -172,7 +172,9 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) { | |||
layout: { | |||
type: | |||
layoutType?.name === | |||
'constrained' | |||
'constrained' || |
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.
Would a const legacyMarkup = !! inherit || !! contentSize
be helpful to clarify why this is needed - could also be used in the checked
prop as well?
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.
Oh, that's much nicer! I'll update, and we can use it in the check for help text, too 👍
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.
Updated.
8173a69
to
bd3b1fd
Compare
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 tested well for me:
✅ Was able to toggle off with a single click with both contentSize and legacy inherit setting
✅ The toggle worked as expected for new blocks
bd3b1fd
to
ebff049
Compare
What?
In the Layout support's
Inner blocks use content width
toggle, ensure that the logic for which layout type to set also factors in whetherinherit
orcontentSize
is set for legacy markup that uses thedefault
layout type.This ensures that for legacy markup (e.g. the Column block) if you go to toggle off the control, it will toggle off when first clicked.
Why?
Without this change, for some legacy markup, if you go to toggle off the control, it appears not to really do anything at first (it's actually updating the layout type from default to
constrained
). To resolve this, in theonChange
callback, let's factor ininherit
andcontentSize
settings in the same way as we do for the checked status.How?
Inner blocks use content width
toggle'sonChange
handler, treat the existence ofinherit
orcontentSize
as signalling that toggling should update the layout attribute to be an emptydefault
layout object.Testing Instructions
Using the following legacy markup, go to toggle off the
Inner blocks use content width
control on the right column:Test markup (the right column has content size)
Test that toggling the control still works as expected for existing Group, Query or individual Column blocks.
Screenshots or screencast
Note that in the before clip, the first click on the toggle clears out the content size, but does not visually set the toggle to false (this is because what's actually happening is that the layout object is being updated to be an empty constrained type). In the after clip, the logic is updated so that it treats the default layout type + contentSize as the same as a constrained layout type, so the toggle is effectively switched off when first clicked.