-
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
Use UnitControl
instead of RangeControl
for column width
#24711
Use UnitControl
instead of RangeControl
for column width
#24711
Conversation
I agree that this change is needed since it will enable more precise layouts. I have tested the PR by creating a couple of column blocks without the plugin installed, and then activating the plugin (master + the pr). The original % values that were saved are working correctly in the editor and front. |
Comment no longer relevant since it refers to a previous implementation using a
Added some rudimentary values validation in |
UnitControl
instead of RangeControl
for column width
@ZebulanStanphill I'm curious, why was the |
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.
Hey @aristath! Thanks for working on this! - I haven't check the branch thoroughly because some more involved into these kind of things folks should have a better context/opinions. @ItsJonQ can you take a look here?
I have left some notes on the deprecation of the block though that I think you should check. I'm not 100% sure if I have missed something from the API or have understood something different, but seems worth asking a few things :)
@aristath Yay!! I made one minor adjustment to the UI (reducing the width of the input) If this you're okay with this, then I think it's ready 👍 |
@ItsJonQ Looks great! ❤️ Yes, of course I'm OK with it. |
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.
Thanks @aristath for this update! 👍 from me
Hello, I would like to discuss some aspects of that PR 🤔
I'm aware that it can be hard to run the mobile, but you can always ping someone from mobile team to test and confirm if changes don't break anything.
and then will open the post on mobile app. |
@aristath What do you think about the regressions above? Can we fix this on time for 5.6 or should we revert this PR temporarily? |
One more thing to note is that function in |
I currently have to focus on the twentytwentyone theme if we want to make the deadline, so I can't work on this issue this week. |
Created a PR to temporarily revert: #26056 |
I think even the revert could potentially affect other merged PRs (after this one) that had to do with And this one is I know because I was the author. There could be many more... 🤔 |
migrate( attributes ) { | ||
return { | ||
...attributes, | ||
width: `${ attributes.width }%`, |
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.
@tellthemachines, @ntsekouras - this one might need isEligible
check. width
might be not set at all. It's very likely we can avoid adding another deprecation in #26757.
"type": "number", | ||
"min": 0, | ||
"max": 100 | ||
"type": "string" |
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 also creates some issues when adding a new column because it still uses number values. See #27756.
I've got an itch I need to scratch... With FSE users will be able to use the editor to create their layouts. However, there is currently no way to create a layout with a side-header, or do a lot of other cool stuff.
The reason why they can't is simple: Columns are restricted to only use percent (
%
) values for their width.This PR changes the control for column width from a
RangeControl
to aUnitControl
, and makes all necessary changes to ensure backwards-compatibility and everything seems to be working the way it should. (see #24193)The width control now looks like this:
The benefit of that is that we can now create a layout like this:
In the screencast above, the left column has a width of
250px
and is the site header.With percentage values that wouldn't be possible unless the user added custom classes and then custom HTML - which is totally possible but is the very thing Gutenberg was created to solve.
You can see there that resizing the viewport doesn't change the width of the 1st column since we used absolute units for that.
Though the range control is admittedly prettier,
UnitControl
allows for greater versatility and can accommodate many more scenarios.EDIT:
Originally this PR aimed to allow arbitrary values for column widths.
Since then I realized the original plan was too ambitious and maybe too confusing for certain users. Some of the first commits here were using a TextControl and a custom validation function with notices. This is no longer the case and I switched it to
UnitControl
which is a more familiar pattern in the editor.