-
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
Persistent List View: Add visual support for multiple selected blocks #29878
Conversation
Size Change: +59 B (0%) Total Size: 1.41 MB
ℹ️ View Unchanged
|
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.
@jameskoster That's actually as I intended and mentioned in the PR description! 🙂
|
5dff276
to
fc7f61b
Compare
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.
Once we have collapse / expand it might be worth collapsing on multi-selection |
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 don't think is a blocker but would be nice to have for the ability to reason about the fact that we're passing multiple client IDs now in param names throughout.
Otherwise, this makes sense and works as advertised. Nice improvement!
@@ -74,7 +74,7 @@ export default function ListViewSidebar() { | |||
<BlockNavigationTree | |||
blocks={ rootBlocks } | |||
selectBlock={ selectEditorBlock } | |||
selectedBlockClientId={ selectedBlockClientId } | |||
selectedBlockClientId={ selectedBlockClientIds } |
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.
Would we maybe want to update the param here and elsewhere to reflect its new, consistently plural state? Eg selectedBlockClientIds={ selectedBlockClientIds }
?
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 for raising this, I was undecided if pursuing it, but in the end it wasn't that complicated.
In 51631bd I've replaced the singular prop with the plural.
Since the BlockNavigationTree
component is exposed by the package, I added a deprecate
message and a little prop conversion for backward compatibility.
(Note: the main BlockNavigation
component is not exported, reason why I handled the deprecation in the sub-component BlockNavigationTree
.)
I've also updated all the consumers of these components to the new array, plural prop.
As the multi-selection is currently only supposed to be supported by the persistent List View, I've chosen to keep the pre-existing behaviour for the other consumers (dropdown List View, and Navigation block's Block Navigation).
Namely: they only highlight singularly selected blocks, while multi-selected blocks are simply ignored.
The technical reason for this is that single and multiple selections refer to different state properties.
5bbeb72
to
c89ff13
Compare
I've rebased this after #29902, which touched roughly the same files as this. I don't see any issues arising from the rebase, but would love a second look before merging this, as it will affect production components. |
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.
🚢 🚀
Can you update the PR description to reflect the latest version?
For example PR description says:
Also, selected nested branches of multi-selected blocks won't be highlighted anymore.
This is a personal choice, as I feel it might add too much visual noise to the list.
And the screenshot is outdated.
Description
Fix #29469
When selecting multiple blocks, the selected client IDs are stored in a separate state property than single selected blocks.
The non-persistent List View has no real reason to support multi-selected blocks, so it's ok for it to not displaying anything as selected when multiple blocks are selected.
On the other hand, the Persistent List View would look odd.
This PR adds visual support to the Persistent List View for multiple selected blocks.
This new feature is gated behind the
__experimentalPersistentListViewFeatures
flag to avoid conflicts with non-persistent uses of the List View.When multiple blocks are selected, opening the List View won't focus on the selected item anymore.
I'm not sure if focusing the first selected item would make more sense, though. 🤔
Note: this PR does not add support for selecting multiple block in the List View.
I'm not sure if it's possible, but I'd rather keep it simple for now.
How has this been tested?
Also check for regressions of the List View dropdown in the Post Editor.
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: