Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
ImageSizeControls: Replace ButtonGroup with ToggleGroupControl #65386
ImageSizeControls: Replace ButtonGroup with ToggleGroupControl #65386
Changes from 1 commit
30dbcb1
05ebec6
1196a22
e740c51
5ee7630
12532be
20d8650
393bb5d
c84ff9f
08f19cd
4979ddd
558cd41
4bc666b
a3d6c29
4fd8d34
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
As discussed here,
isDeselectable
doesn't really work with text options — we should remove it.One option could be to add an "Auto" option which replaces the 'reset' button. What do you think, @mirka @t-hamano ?
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.
If we remove the
isDeselectable
prop, keyboard users won't be able to set a custom value:71dcd41756d30d74f869d014456c5284.mp4
As I commented here too, we might need to add an option called "Custom".
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 isn't inherently true — it's only because the logic of
addSelectedScaleValue
doesn't account for it. In fact the current logic sets invalid values on the ToggleGroupControl, when it should be set back toundefined
instead. (cc @hbhalodia)For the sake of this PR, I'm ok with just replicating the existing functionality. And as it turns out, the Reset button doesn't actually reset, it just sets it to 100%, which is different from an actual reset. So to actually reset, the user needs to clear the width/height input fields. I think that means we don't even need a Reset button nor a "Custom" option to replicate the existing functionality.
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.
Hi @mirka, If I had read it correct, need to update the logic on
addSelectedScaleValue()
function should returnundefined
, when we set custom values? is that something need to changed.Thank You,
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.
Hi @mirka, I tried to set directly undefined on that logic, seems like anyhow keyboard user would ultimately land on the first option of the
ToggleGroupControl
, which ultimately sets the first option even we have undefined set on that logic.Can you please let me know how to set it undefined for keyboard users on that logic, because ultimately when user lands on the
toggleGroupControl
it would callhandleUpdateDimension()
which ultimately sets the dimension based on the scale size, and it would remove the custom dimension set.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.
Hi @mirka @t-hamano, This is now looking good. Below is the demo screencast. I guess we can go ahead with the PR, let me know if I need to address any other feedbacks.
GBissue-65339.mov
Thank You,
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.
I may have lost the plot a little bit, but I noticed that unit tests are failing because they require a "reset" button. With the changes from this PR, would a user be able to reset the value at all? Is that something that we should retain?
Again, apologies in case I missed the part of the conversation where we reached an agreement on that aspect.
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.
The reset button in the original was the functional equivalent of re-selecting the "100%" option. The user can also still delete the values from the number inputs. So, I'd say no functionality is lost.
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.
In the current specification, when we press the reset button, the width/height values are set and 100% is selected. These values are not saved in the database. In addition, when we reload the browser, the width/height values and the 100% selection are cleared.
This lack of consistency bothers me, but at least the reset action is considered to be the same as 100%, so I think a reset button is not necessary.
4ba662ea53e68b1a6cfa11351a23a5db.mp4
The presence or absence of a reset button has been discussed in other PRs, and there may not be a complete consensus yet, but my understanding is as follows:
auto
). One approach being considered is adding an "Auto" option.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.
Thank you, Lena and Aki — much more clear now. We established that no functionality is lost.
The lack of consistency is also bothering me. I say we merge this PR with the current UX, and then we look at opportunities for improving consistency across other PRs
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 might make sense for the percentage string to be localized. In some languages, it might actually be displayed differently:
https://phrase.com/blog/posts/number-localization/#toc_5
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.
Do we localize other percentages across Gutenberg? If not, it may be better to split it to a separate PR to localize all percentages at the same time
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.
I do not think, we are localizing other percentage implementations, here is the example for column block -
gutenberg/packages/block-library/src/column/edit.js
Line 84 in 9b0f6aa
I agree with @ciampo, to add all at once, so it does not block the scope of this PR.
Thank You,
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.
I filed issue #66298 regarding localizing percentage values.