-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Block Library: Column: Limit width redistribution to adjacent column #16822
Conversation
I know @aduth is not around at the moment to follow up, but I thought I'd give this a review. I don't think the approach taken is quite right. Even though this should prevent non-adjacent columns from changing I still see them moving when I'm resizing. In testing I used three columns (one of the predefined layouts). I think the issue is due to the current calculation not being quite right, and it's causing some glitchy widths. For example, If I add width onto column A it should take it from column B. But if column B doesn't have any more width to give it ends up with a negative percentage. I think column C then adjusts to take up that 'negative' percentage space. I noticed it was also possible to get more than 100% for a column width if you mess around enough. I also tried typing specific widths into the columns to make them exact (e.g. 25, 25, 50), but the trouble is that as soon as you type the adjacent column re-adjusts, it actually seems very hard to type the desired widths. Some options:
|
Some further thoughts (as if I hadn't written enough)
|
I recall considering this, and I can't remember specifically why it was this wasn't the direction taken. As you allude, it would remove some of what exists today in enforcing that the columns will always sum 100% width by allowing the user direct control over each of those values. I'm unsure, but there may be some challenge in applying those flex styling within the editor, though I don't think that should necessarily affect the decision for what is the most correct approach here. |
10d9b09
to
5001270
Compare
Following discussion at #19515, I rebased this branch to explore what might be necessary to resolve the outstanding issues presented in @talldan's earlier review. The current branch represents a revised approach where, when the width of a column changes, it will take or add to the immediately adjacent block, and if that block has no width to give or receive, it will consecutively step through and repeat this adjustment on as many of the remaining adjacent blocks as necessary. It works reasonably okay, but there are a few non-obvious scenarios to try to deal with, where each could have the potential to be an unexpected change from the user's perspective:
A live environment for testing is available at: http://gutenberg.run/16822 Note: The implementation is rough, and I've not yet updated the tests. The above behaviors may in-fact be buggy or not working correctly, but I've described them as to what my expectation would be based on how I approached the implementation. By sharing early progress, my intent is to illustrate that, while this approach can be more predictable in many ways than the existing implementation, there are a number of scenarios where the expected outcome of a width adjustment may not be immediately obvious to a user. I also think it could make sense to consider sensible maximums and minimums in the adjustment. The above examples show that it can be possible to arrive at a scenario where a column in a set of columns could have Consider again this example:
With a minimum column width of |
Just going to list a few quirks which you may already be aware of:
|
Since #19515 is merged, this is no longer immediately applicable. It may be revisited as discussion of columns widths controls continues. |
Closes #16370 (cc @phpbits)
This pull request seeks to improve the behavior of column width assignment to limit impact on other columns, to redistribute width relative only the block immediately adjacent the one being resized, rather than split amongst all other blocks in the set. It is hoped that this should be a more predictable behavior for resizing, particularly when aiming to resize multiple columns.
Testing Instructions:
Verify that resizing a column adds or removes width from the column immediately to its right (if the column is the last in the set, it adds or removes from the column to its left).