Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Block Switcher: Render disabled button even if multi-selection #13431
Previously: #11600 (comment)
This pull request seeks to remove a condition present in the
Without these changes, there is an inconsistency based on an assumption that transformations can only apply to a set of blocks of the same type. While currently true, there is not a guarantee that this will always be the case, and the component itself otherwise makes no expectation that it would be (if transformations exist, a dropdown will be shown with the icon of the first block, regardless of whether all blocks in the selection are of the same type). Additionally, the current behavior would cause nothing to be rendered even if the multi-selection was of blocks of the same type, if there were no multi-transforms for multiple blocks of that type. This is inconsistent with both multi-selections of the same type where a transformation does exist (dropdown shown with icon of that block type), and singular selections of a type where no transformation exists (dropdown not shown, but disabled icon shown of that block type).
This does present an awkward scenario where multiple blocks of different types shows an icon of the first type:
Instead, we may consider:
Verify that the BlockSwitcher is shown always, regardless of the blocks composing the selection. The icon should correspond to the first block in the selection, and should be disabled if and only if there are neither valid transforms nor applicable styles to choose from.
I dig it, thanks for the work. I think it is correct to use a disabled-looking (because it is disabled) icon in the switcher, when no transformation is necessary.
Is it maybe an opportunity to explain what is going on — can a disabled button show a tooltip? Like if you hovered the disabled button, could it say "No transformations available", or something to that effect?
It really would be nice if we could swap out that "first of type" icon with something else. Perhaps this?
Also, this made me realize (which is completely unrelated to this branch and should not be fixed here) that we are scaling down the block icons! ┻━┻ ︵ヽ(`Д´)ﾉ︵ ┻━┻
The material icons are 24x24, but it's scaled down to 20x20. Which makes them blurry on the majority of screens in the world:
When/how did this regress? I feel like we just fixed that recently. I think we might need an e2e test for icons :D
@jasmussen those pesky icons! Might be worth looking into screenshot tests for some of the UI stuff that regresses regularly.
I like the idea of a separate icon for multi-block switching that spans multiple block types, but I'm also not too bothered by the first-block-type icon if it's radically easier. I think the benefits here outweigh the costs.
gziolo left a comment •
Let's do it
We don't do it also for blocks which don't offer transformations. I think it should be tackled separately.
Another thing we could do in its own PR, which I raised in the past, is
It could also render the disabled icon for consistency.
I've pushed some updates per feedback, specifically using a different icon when blocks in a selection are not of same type.
Same type, with transforms available (no change from master):
Different type, no transforms available (master would have shown nothing):
Same type, no transforms available (master would have shown nothing):