-
Notifications
You must be signed in to change notification settings - Fork 4.7k
List View: Add smart expansion for nested blocks #74319
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
base: trunk
Are you sure you want to change the base?
List View: Add smart expansion for nested blocks #74319
Conversation
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @JosVelasco! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Implements automatic depth adjustment for List View based on block count as a Gutenberg experiment. When enabled, the List View will automatically collapse deeper levels when the visible block count exceeds a configurable threshold (default: 20 blocks). Key features: - Gutenberg experiment with admin toggle - User-configurable max visible blocks setting (5-200, default 20) - Performance optimizations with early exits and Core selector integration - Settings panel in Editor Preferences > General > List View - Debug mode for development (DEBUG_DYNAMIC_EXPANSION flag) The feature improves performance and usability for sites with deeply nested block structures while maintaining full expansion for simpler pages. Fixes WordPress#53004.
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thank you, @JosVelasco! This is an interesting experiment. The List View renders a fixed number of items initially, using virtualization for large lists. I'm not sure if providing a way to set a threshold above this number would be beneficial. Maybe instead of providing this option, we use a smart default that matches the maximum number of initial items. Here's the code responsible for this logic: gutenberg/packages/block-editor/src/components/list-view/index.js Lines 323 to 340 in 3cd52a4
|
|
+1 this is an impressive exploration. It'd be good to loop in some designers for feedback when you're ready as the behaviour in the list view can be quite challenging to get intuitive, but I appreciate that a lot of thought has gone into this one! Something I'm wondering from looking at the code change — is there a way to simplify this, i.e. for it to be a binary "expand all if less total blocks than a threshold" rather than figuring out the exact level of depth to expand to? Or does it feel key that it should take care to handle particular levels of depth? My main concern is about whether the additional complexity is worth the benefit, though the logic here is quite clever. |
|
Hi @andrewfleming and @Mamaduka. Thanks for your comments! Before experimenting further, please take a look at this simpler alternative. |
Closes #53004
What?
Adds a Gutenberg experiment that implements dynamic expansion depth adjustment for the List View. When enabled, the List View automatically collapses deeper nesting levels to maintain optimal performance and usability.
Why?
The List View can become difficult to navigate and slow to render when dealing with deeply nested block structures (issue #53004). Users need a way to work with complex page hierarchies without performance degradation or overwhelming visual clutter.
How?
getGlobalBlockCount()selectorDEBUG_DYNAMIC_EXPANSIONflag in code)Testing Instructions
Test Case 1: Enable Experiment and Basic Functionality
Test Case 2: Settings Panel
Test Case 3: Small Pages
Video
expand-nesting.mp4