Only prioritise Quote transform where relevant#57749
Conversation
|
Size Change: +2.48 kB (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
andrewserong
left a comment
There was a problem hiding this comment.
Great catch! This feels much better to me, and it doesn't feel at all like a negative that when selecting a Heading and a Paragraph block at the same time, Quote is now at the bottom of the transform list. There's only three items in the transform list anyway, so the trade-off very much feels worth it to me 👍
✅ Quote is in the list of priority transforms on single text block selection
✅ Quote is deprioritised when selecting multiple blocks
✅ Quote is at the bottom of the list when selecting multiple image blocks
| Before | After |
|---|---|
![]() |
![]() |
LGTM! ✨
| }, | ||
| { priorityTextTransformations: [], restTransformations: [] } | ||
| ); | ||
| if ( |
There was a problem hiding this comment.
Is it worth adding an explanatory comment as to why we don't want core/quote to be the only priority transform? Just wondered if it'd help anyone looking at this further down the track to know why there's a bit of extra code to shove it out of the way.
There was a problem hiding this comment.
Ah yes, that's a great point! It should be made clear that if the priority list changes, this code might have to change too.
| /** | ||
| * If there is only one priority text transformation and it's a Quote, | ||
| * is should move to the rest transformations. This is because Quote can | ||
| * be a container for any block type, so in multi-block selection it will | ||
| * always be suggested, even for non-text blocks. | ||
| */ |


What?
Iterates on #40208.
#44072 hardcoded a list of "priority" transforms for text blocks, including Paragraph, Heading, List and Quote. The problem with including Quote in this list is that it's a generic container block, so any block or selection of blocks is allowed to transform into it. This results in Quote being unexpectedly singled out as a priority transform in situations where it doesn't make sense at all, such as when two Images are selected:
This PR fixes the issue by checking whether Quote is the only available priority transform, and assuming that's a reliable indicator of its irrelevance. This means Quote is no longer shown as a priority when any two text blocks (such as Verse and Code) are selected, but it is still shown for any single text block. I think this is a reasonable tradeoff to fix the currently very confusing experience.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast