-
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
List View: Expand state if a block is dragged to within a collapsed block in the editor canvas #56493
List View: Expand state if a block is dragged to within a collapsed block in the editor canvas #56493
Conversation
…lock in the editor canvas
Size Change: -10 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
const parentClientIds = | ||
Array.isArray( selectedBlockParentClientIds ) && | ||
selectedBlockParentClientIds.length | ||
? selectedBlockParentClientIds | ||
: null; | ||
|
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 has been removed so that we can use selectedBlockParentClientIds
in the useEffect
dependency array — in theory at least, selectedBlockParentClientIds
should only be a new array when there really has been a change and we wish to perform an update, since it gets returned by the useSelect
instead of being instantiated on each render.
Although, now that I say that, parentClientIds
was probably already a reference to that array, so maybe this change wasn't needed 🤔
In any case, I think it's a little neater without parentClientIds
, but happy to revert if folks prefer.
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 selectedBlockParentClientIds?.length
does the same job, LGTM to remove it :)
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.
Works a treat.
2023-11-24.16.37.17.mp4
Thanks for reviewing! 🙇 |
What?
Part of #49563 and #33683. Also, partially related to #33684.
In the list view, when a block is dragged to a different part of the document (i.e. when dragged to a child of a collapsed block) ensure that the tree is expanded for the selected block in its new position.
Why?
This resolves an issue where if you drag a block with the list view open, it's possible for the dragged block to no longer be visible in the list view, when you drag to another part of the document that is collapsed.
How?
If the selected block's parents has changed, then update the expanded state for the block's parents.
Testing Instructions
useEffect
called too frequently, or just when expected?Testing Instructions for Keyboard
Screenshots or screencast
Before
2023-11-24.15.56.58.mp4
After
2023-11-24.15.57.30.mp4