Skip to content
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: Add keyboard shortcut to collapse list view items other than the focused item #59978

Merged

Conversation

andrewserong
Copy link
Contributor

@andrewserong andrewserong commented Mar 19, 2024

What?

Fixes #59936

Add a keyboard shortcut where ⌥L collapses all other nested groups except the one you have selected.

Why?

When navigating deeply nested list views, it could be handy to be able to quickly collapse everything other than the currently focused list view item. The approach in this PR is inspired by the behaviour in Figma.

How?

  • Add a new keyboard shortcut category for the list view, as this is the first keyboard shortcut that is exclusive to this part of the block editor UI
  • When someone uses this keyboard shortcut, collapse all items except for the tree of parents of the currently focused item
  • Allow the keyboard shortcut from the editor canvas, if focus is not currently within a text field

Testing Instructions

  1. In the post, site, and widget editors, test browsing nested list views and that pressing the keyboard shortcut ⌥L (Option-L on Mac, or Alt-L on Windows) collapses all of the list view except for the currently focused part of the tree, when focus is within the list view.
  2. Does this feel like the right keyboard shortcut to use: i.e. is copying the one used by Figma a natural fit?
  3. Double-check the keyboard shortcuts screen that the newly added keyboard shortcut text reads well (or propose some alternate text if you think we can tighten it up)

Screenshots or screencast

The new behaviour:

2024-03-19.16.05.27.mp4

The item in the list of keyboard shortcuts:

image
@andrewserong andrewserong added [Type] Enhancement A suggestion for improvement. [Feature] List View Menu item in the top toolbar to select blocks from a list of links. labels Mar 19, 2024
@andrewserong andrewserong self-assigned this Mar 19, 2024
Copy link

github-actions bot commented Mar 19, 2024

Size Change: +1.99 kB (0%)

Total Size: 1.72 MB

Filename Size Change
build/block-editor/index.min.js 253 kB +683 B (0%)
build/block-editor/style-rtl.css 15.6 kB +2 B (0%)
build/block-editor/style.css 15.6 kB -2 B (0%)
build/block-library/blocks/audio/theme-rtl.css 133 B +7 B (+6%) 🔍
build/block-library/blocks/audio/theme.css 133 B +7 B (+6%) 🔍
build/block-library/blocks/cover/style-rtl.css 1.7 kB +7 B (0%)
build/block-library/blocks/cover/style.css 1.69 kB +7 B (0%)
build/block-library/blocks/embed/theme-rtl.css 133 B +7 B (+6%) 🔍
build/block-library/blocks/embed/theme.css 133 B +7 B (+6%) 🔍
build/block-library/blocks/file/editor-rtl.css 326 B +10 B (+3%)
build/block-library/blocks/file/editor.css 327 B +11 B (+3%)
build/block-library/blocks/image/theme-rtl.css 133 B +7 B (+6%) 🔍
build/block-library/blocks/image/theme.css 133 B +7 B (+6%) 🔍
build/block-library/blocks/pullquote/theme-rtl.css 174 B +6 B (+4%)
build/block-library/blocks/pullquote/theme.css 174 B +6 B (+4%)
build/block-library/blocks/quote/theme-rtl.css 233 B +10 B (+4%)
build/block-library/blocks/quote/theme.css 235 B +9 B (+4%)
build/block-library/blocks/social-links/editor-rtl.css 678 B -4 B (-1%)
build/block-library/blocks/social-links/editor.css 678 B -3 B (0%)
build/block-library/blocks/table/theme-rtl.css 152 B +6 B (+4%)
build/block-library/blocks/table/theme.css 152 B +6 B (+4%)
build/block-library/blocks/template-part/editor-rtl.css 431 B +28 B (+7%) 🔍
build/block-library/blocks/template-part/editor.css 431 B +28 B (+7%) 🔍
build/block-library/blocks/template-part/theme-rtl.css 107 B +6 B (+6%) 🔍
build/block-library/blocks/template-part/theme.css 107 B +6 B (+6%) 🔍
build/block-library/blocks/video/theme-rtl.css 133 B +7 B (+6%) 🔍
build/block-library/blocks/video/theme.css 133 B +7 B (+6%) 🔍
build/block-library/editor-rtl.css 12.4 kB +33 B (0%)
build/block-library/editor.css 12.4 kB +34 B (0%)
build/block-library/index.min.js 218 kB +184 B (0%)
build/block-library/style-rtl.css 14.8 kB +9 B (0%)
build/block-library/style.css 14.8 kB +5 B (0%)
build/block-library/theme-rtl.css 707 B +19 B (+3%)
build/block-library/theme.css 713 B +20 B (+3%)
build/blocks/index.min.js 51.8 kB +18 B (0%)
build/components/index.min.js 223 kB -312 B (0%)
build/components/style-rtl.css 11.8 kB -17 B (0%)
build/components/style.css 11.8 kB -17 B (0%)
build/core-data/index.min.js 72.9 kB +126 B (0%)
build/customize-widgets/index.min.js 11.2 kB +22 B (0%)
build/edit-post/index.min.js 24 kB -156 B (-1%)
build/edit-post/style-rtl.css 5.56 kB -15 B (0%)
build/edit-post/style.css 5.56 kB -14 B (0%)
build/edit-site/index.min.js 217 kB -379 B (0%)
build/edit-site/style-rtl.css 15.1 kB +128 B (+1%)
build/edit-site/style.css 15.1 kB +133 B (+1%)
build/edit-widgets/index.min.js 17.4 kB +35 B (0%)
build/edit-widgets/style-rtl.css 4.15 kB -13 B (0%)
build/edit-widgets/style.css 4.15 kB -13 B (0%)
build/editor/index.min.js 65.1 kB +1.11 kB (+2%)
build/editor/style-rtl.css 5.43 kB +78 B (+1%)
build/editor/style.css 5.43 kB +79 B (+1%)
build/format-library/index.min.js 8.1 kB +73 B (+1%)
build/style-engine/index.min.js 2.03 kB -68 B (-3%)
build/widgets/index.min.js 7.22 kB +12 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 955 B
build/annotations/index.min.js 2.69 kB
build/api-fetch/index.min.js 2.32 kB
build/autop/index.min.js 2.1 kB
build/blob/index.min.js 578 B
build/block-directory/index.min.js 7.26 kB
build/block-directory/style-rtl.css 1.03 kB
build/block-directory/style.css 1.03 kB
build/block-editor/content-rtl.css 4.43 kB
build/block-editor/content.css 4.43 kB
build/block-editor/default-editor-styles-rtl.css 394 B
build/block-editor/default-editor-styles.css 394 B
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 415 B
build/block-library/blocks/button/editor.css 414 B
build/block-library/blocks/button/style-rtl.css 627 B
build/block-library/blocks/button/style.css 626 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 421 B
build/block-library/blocks/columns/style.css 421 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 647 B
build/block-library/blocks/cover/editor.css 650 B
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 98 B
build/block-library/blocks/details/style.css 98 B
build/block-library/blocks/embed/editor-rtl.css 322 B
build/block-library/blocks/embed/editor.css 322 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/file/style-rtl.css 280 B
build/block-library/blocks/file/style.css 281 B
build/block-library/blocks/file/view.min.js 324 B
build/block-library/blocks/footnotes/style-rtl.css 201 B
build/block-library/blocks/footnotes/style.css 199 B
build/block-library/blocks/form-input/editor-rtl.css 227 B
build/block-library/blocks/form-input/editor.css 227 B
build/block-library/blocks/form-input/style-rtl.css 343 B
build/block-library/blocks/form-input/style.css 343 B
build/block-library/blocks/form-submission-notification/editor-rtl.css 340 B
build/block-library/blocks/form-submission-notification/editor.css 340 B
build/block-library/blocks/form-submit-button/style-rtl.css 69 B
build/block-library/blocks/form-submit-button/style.css 69 B
build/block-library/blocks/form/view.min.js 471 B
build/block-library/blocks/freeform/editor-rtl.css 2.61 kB
build/block-library/blocks/freeform/editor.css 2.61 kB
build/block-library/blocks/gallery/editor-rtl.css 947 B
build/block-library/blocks/gallery/editor.css 952 B
build/block-library/blocks/gallery/style-rtl.css 1.72 kB
build/block-library/blocks/gallery/style.css 1.72 kB
build/block-library/blocks/gallery/theme-rtl.css 108 B
build/block-library/blocks/gallery/theme.css 108 B
build/block-library/blocks/group/editor-rtl.css 647 B
build/block-library/blocks/group/editor.css 647 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 189 B
build/block-library/blocks/heading/style.css 189 B
build/block-library/blocks/html/editor-rtl.css 336 B
build/block-library/blocks/html/editor.css 337 B
build/block-library/blocks/image/editor-rtl.css 878 B
build/block-library/blocks/image/editor.css 878 B
build/block-library/blocks/image/style-rtl.css 1.6 kB
build/block-library/blocks/image/style.css 1.59 kB
build/block-library/blocks/image/view.min.js 1.54 kB
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 478 B
build/block-library/blocks/latest-posts/style.css 478 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 B
build/block-library/blocks/media-text/editor-rtl.css 306 B
build/block-library/blocks/media-text/editor.css 305 B
build/block-library/blocks/media-text/style-rtl.css 505 B
build/block-library/blocks/media-text/style.css 503 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 668 B
build/block-library/blocks/navigation-link/editor.css 669 B
build/block-library/blocks/navigation-link/style-rtl.css 259 B
build/block-library/blocks/navigation-link/style.css 257 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 296 B
build/block-library/blocks/navigation-submenu/editor.css 295 B
build/block-library/blocks/navigation/editor-rtl.css 2.26 kB
build/block-library/blocks/navigation/editor.css 2.26 kB
build/block-library/blocks/navigation/style-rtl.css 2.26 kB
build/block-library/blocks/navigation/style.css 2.25 kB
build/block-library/blocks/navigation/view.min.js 1.02 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 377 B
build/block-library/blocks/page-list/editor.css 377 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 235 B
build/block-library/blocks/paragraph/editor.css 235 B
build/block-library/blocks/paragraph/style-rtl.css 335 B
build/block-library/blocks/paragraph/style.css 335 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 508 B
build/block-library/blocks/post-comments-form/style.css 508 B
build/block-library/blocks/post-content/editor-rtl.css 74 B
build/block-library/blocks/post-content/editor.css 74 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 666 B
build/block-library/blocks/post-featured-image/editor.css 662 B
build/block-library/blocks/post-featured-image/style-rtl.css 342 B
build/block-library/blocks/post-featured-image/style.css 342 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 409 B
build/block-library/blocks/post-template/style.css 408 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 69 B
build/block-library/blocks/post-time-to-read/style.css 69 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 354 B
build/block-library/blocks/pullquote/style.css 354 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 486 B
build/block-library/blocks/query/editor.css 486 B
build/block-library/blocks/query/view.min.js 958 B
build/block-library/blocks/quote/style-rtl.css 237 B
build/block-library/blocks/quote/style.css 237 B
build/block-library/blocks/read-more/style-rtl.css 140 B
build/block-library/blocks/read-more/style.css 140 B
build/block-library/blocks/rss/editor-rtl.css 149 B
build/block-library/blocks/rss/editor.css 149 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 184 B
build/block-library/blocks/search/editor.css 184 B
build/block-library/blocks/search/style-rtl.css 629 B
build/block-library/blocks/search/style.css 628 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/search/view.min.js 478 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 229 B
build/block-library/blocks/separator/style.css 229 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 323 B
build/block-library/blocks/shortcode/editor.css 323 B
build/block-library/blocks/site-logo/editor-rtl.css 754 B
build/block-library/blocks/site-logo/editor.css 754 B
build/block-library/blocks/site-logo/style-rtl.css 204 B
build/block-library/blocks/site-logo/style.css 204 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 B
build/block-library/blocks/social-links/style-rtl.css 1.48 kB
build/block-library/blocks/social-links/style.css 1.48 kB
build/block-library/blocks/spacer/editor-rtl.css 350 B
build/block-library/blocks/spacer/editor.css 350 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 395 B
build/block-library/blocks/table/editor.css 395 B
build/block-library/blocks/table/style-rtl.css 639 B
build/block-library/blocks/table/style.css 639 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/term-description/style-rtl.css 111 B
build/block-library/blocks/term-description/style.css 111 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 185 B
build/block-library/blocks/video/style.css 185 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.11 kB
build/block-library/common.css 1.11 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/commands/index.min.js 15.6 kB
build/commands/style-rtl.css 935 B
build/commands/style.css 930 B
build/compose/index.min.js 12.6 kB
build/core-commands/index.min.js 2.77 kB
build/customize-widgets/style-rtl.css 1.36 kB
build/customize-widgets/style.css 1.36 kB
build/data-controls/index.min.js 640 B
build/data/index.min.js 8.98 kB
build/date/index.min.js 17.9 kB
build/deprecated/index.min.js 451 B
build/dom-ready/index.min.js 324 B
build/dom/index.min.js 4.65 kB
build/edit-post/classic-rtl.css 558 B
build/edit-post/classic.css 558 B
build/element/index.min.js 4.83 kB
build/escape-html/index.min.js 537 B
build/format-library/style-rtl.css 492 B
build/format-library/style.css 490 B
build/hooks/index.min.js 1.55 kB
build/html-entities/index.min.js 448 B
build/i18n/index.min.js 3.58 kB
build/interactivity/file.min.js 447 B
build/interactivity/image.min.js 1.67 kB
build/interactivity/index.min.js 13 kB
build/interactivity/navigation.min.js 1.15 kB
build/interactivity/query.min.js 740 B
build/interactivity/router.min.js 1.36 kB
build/interactivity/search.min.js 618 B
build/is-shallow-equal/index.min.js 527 B
build/keyboard-shortcuts/index.min.js 1.74 kB
build/keycodes/index.min.js 1.46 kB
build/list-reusable-blocks/index.min.js 2.11 kB
build/list-reusable-blocks/style-rtl.css 851 B
build/list-reusable-blocks/style.css 849 B
build/media-utils/index.min.js 2.92 kB
build/modules/importmap-polyfill.min.js 12.2 kB
build/notices/index.min.js 948 B
build/nux/index.min.js 2 kB
build/nux/style-rtl.css 747 B
build/nux/style.css 742 B
build/patterns/index.min.js 5.73 kB
build/patterns/style-rtl.css 553 B
build/patterns/style.css 552 B
build/plugins/index.min.js 1.8 kB
build/preferences-persistence/index.min.js 2.05 kB
build/preferences/index.min.js 2.81 kB
build/preferences/style-rtl.css 710 B
build/preferences/style.css 712 B
build/primitives/index.min.js 975 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 1 kB
build/react-i18n/index.min.js 623 B
build/react-refresh-entry/index.min.js 9.47 kB
build/react-refresh-runtime/index.min.js 6.78 kB
build/redux-routine/index.min.js 2.7 kB
build/reusable-blocks/index.min.js 2.73 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.5 kB
build/router/index.min.js 1.79 kB
build/server-side-render/index.min.js 1.96 kB
build/shortcode/index.min.js 1.39 kB
build/token-list/index.min.js 582 B
build/url/index.min.js 3.72 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.7 kB
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 957 B
build/warning/index.min.js 249 B
build/widgets/style-rtl.css 1.17 kB
build/widgets/style.css 1.17 kB
build/wordcount/index.min.js 1.02 kB

compressed-size-action

Copy link

github-actions bot commented Mar 20, 2024

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 props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @jarekmorawski.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: jarekmorawski.

Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jasmussen
Copy link
Contributor

Based on the video, this is fantastic, such a quality of life feature, thank you.

I can't get it to work, though! ⌥L doesn't do anything for me. I wonder if it's because I'm on a Danish keyboard? It could also be my env.

By the way, nice work also adding it to the keyboards list:
keyboard sheet

But instead of saying "Collapse all but the focused list view item", can it simply say "Collapse all items"? Happy to hear suggestions, mainly wondering if there's a shorter sentence we can use to make it easier to understand. Not collapsing the selection feels implied, though if that needs to be explicit we can keep this, perhaps "Collapse all other items". Figma calls it "Collapse all layers".

@jarekmorawski
Copy link

This is pretty awesome! I know I'll appreciate this improvement as a user. I wonder if we should also add a mouse shortcut? For instance, we'd collapse all other items when I click on the chevron while holding or .

@aaronrobertshaw
Copy link
Contributor

While I haven't gotten to look closely at the code yet, I have given this a quick test and there does appear to be a small issue as Joen noted.

I can't get it to work, though!

Initially, I thought it wasn't working at all for me as well, however, I did notice that if I specifically focus one of the items in the list view and then use the shortcut it behaves as expected.

@jasmussen can you confirm the same behaviour using your keyboard?

Screen.Recording.2024-03-20.at.6.24.41.PM.mp4
@jasmussen
Copy link
Contributor

Oh right, yes, that fixes it. It works when a list item is focused. I would ideally like to see it working also if a list item is just selected.

@andrewserong
Copy link
Contributor Author

Thanks for the feedback, folks! It sounds like I'll need to add handling for when focus is in the editor canvas, but the list view is open. I think I should be able to get that to work, I'll do a little more digging 👍

This is pretty awesome! I know I'll appreciate this improvement as a user. I wonder if we should also add a mouse shortcut? For instance, we'd collapse all other items when I click on the chevron while holding ⌥ or ⌘.

That's a great idea to have a way for it to also be done via the mouse. Let's leave that aside for this particular PR so that we can focus on the keyboard shortcut on its own, but I'll make a note for us to pursue that idea in a follow-up.

Not collapsing the selection feels implied, though if that needs to be explicit we can keep this, perhaps "Collapse all other items"

"Collapse all other items" sounds good to me, I'll update.

@ramonjd
Copy link
Member

ramonjd commented Mar 21, 2024

Just tested, also working well for me.

I had more success using keyboard navigation, since the elements were focussed.

2024-03-21.11.39.08.mp4

As with others, I had to focus the list element when testing with a mouse. Clicking twice to be able to use the shortcut is the same amount of clicks I'd need to use the chevron.

The approach in this PR is inspired by the behaviour in Figma.

Is there a standard when it comes to collapsing/expanding? I had a look around at other apps and am seeing a combo of ⌥ or ⌘ + Arrow keys, or ⌥ or ⌘ + plus/minus keys.

I ask because wondering if it would be useful to be able to expand as well via keyboard shortcut. If so, it might be nice to select a key combo whose shortcuts are the inverse of one another, e.g., arrow keys

Or, if we allow mouse clicking on the chevron while holding ⌥ or ⌘ to expand and collapse, then ⌥ or ⌘ + Enter so that they're analogous.

I dunno 🤷🏻

@andrewserong
Copy link
Contributor Author

Thanks for testing!

Is there a standard when it comes to collapsing/expanding? I had a look around at other apps and am seeing a combo of ⌥ or ⌘ + Arrow keys, or ⌥ or ⌘ + plus/minus keys.

I couldn't find a standard for expanding or collapsing the whole tree. Out of curiosity, which apps were you looking at? And was this expanding or collapsing just the highlighted item, or the entire list?

I ask because wondering if it would be useful to be able to expand as well via keyboard shortcut. If so, it might be nice to select a key combo whose shortcuts are the inverse of one another, e.g., arrow keys

Yes, that would be useful. In the case of expanding, were you imagining a keyboard shortcut to expand all collapsed blocks? At the moment, we can expand or collapse the current block by keyboard by pressing the right and left arrow keys, but that's not quite the same 🤔. I think I'd lean toward looking at a keyboard shortcut for "expand all" to a separate PR potentially, as it might be challenging to determine whether a subsequent press of ⌥L should expand. But it would be neat if you could effectively toggle the expansion state.

@andrewserong
Copy link
Contributor Author

andrewserong commented Mar 21, 2024

Update: I believe I have the keyboard short working from the editor canvas. In order to allow the keyboard shortcut there I needed to add some extra state to the block-editor store along with a private action and selector. Given that list views have local (to the component) state for the expanded state, if we're doing anything outside of the list view itself, we need this extra state in order for it to work. I think this is probably the simplest way to do it, but happy for any ideas if folks can think of a better approach. I've made the action and selector private, and it seems to be working okay in testing, though there's possibly some edge cases. On to the next question:

Which keyboard shortcut shall we go with?

The main issue now is that if you're in a rich text field and you press ⌥L it outputs the ¬ character:

image

So, I think @ramonjd might be onto something in terms of thinking about a different keyboard shortcut to use. @jasmussen do you have any ideas for what might work? If we're allowing the shortcut from within the editor canvas, then I believe it needs to be a shortcut that doesn't conflict with characters that a user might be trying to intentionally output in that area.

I've pretty much filled up my timebox for this PR for this week, but I'll continue hacking on it next week. If the block-editor state idea isn't too bad, I'll add some tests for it when I return to this PR.

Thanks again for the testing and enthusiasm, everyone! It's feeling like we'll be able to make this PR viable once we settle on a good keyboard shortcut and smooth over some of the rough edges 🤞

Copy link

Flaky tests detected in 3cd869b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8370028268
📝 Reported issues:

@ramonjd
Copy link
Member

ramonjd commented Mar 21, 2024

Out of curiosity, which apps were you looking at?

JetBrains and Excel, but they vary across apps and there doesn't appear to be a standard 🤷🏻

Screenshot 2024-03-21 at 4 52 34 pm

I guess that means we could decide based on what makes sense in the Gutenberg context, i.e., given the current UX of the list block.

@andrewserong
Copy link
Contributor Author

Just another thought before I wrap up for the week: I didn't have much luck finding a standard for this kind of shortcut. All the examples I could find were for UIs where focus is already within the list view equivalent, rather than within an editor canvas (so CMD+Left/Right arrow is natural there, where it would interfere with navigating across text when used in a text field in the editor canvas). We also can't use CMD+ or CMD- as browsers use them for zoom. So, a couple of ideas:

  • We could still go with ⌥L but only respect it in the editor canvas if the focus is not within a rich text field. This would have the downside that the keyboard shortcut would not work in Heading and Paragraph blocks, so could feel unexpected / unpredictable, which means we might be better off to:
  • Pick another keyboard shortcut. As one example, the Apple Human Interface Guidelines recommend Prefer the Command key as the main modifier key in a custom keyboard shortcut, which sounds promising at first. However, we also need to be careful to avoid conflicts with browser keyboard shortcuts, and in Safari CMD+L goes to the search bar, so we'd need something more specific.

I'll continue chipping away at this PR next week, and add in some more tests. Let me know if anyone has ideas for potential keyboard shortcut combinations to try!

@jasmussen
Copy link
Contributor

Just to be sure, is there a conflict in making ⌥L a global shortcut to collapse all other groups than the selected one, regardless of where focus is? We can certainly choose another shortcut if need be, but as this is especially useful in the site editor, I imagine going with Figma as the precedence here is a good place to start.

@ramonjd
Copy link
Member

ramonjd commented Mar 24, 2024

However, we also need to be careful to avoid conflicts with browser keyboard shortcuts, and in Safari CMD+L goes to the search bar, so we'd need something more specific.

⌘ + l also jumps to the address bar in Chrome

We could still go with ⌥L but only respect it in the editor canvas if the focus is not within a rich text field.

I'm pretty neutral about Alt+l - it's fine as a custom shortcut. Conversely, it's seems randomly allocated.

Nothing wrong with doing what Figma does if there's a good reason to do so and it's not just Figma bias 😄

Here are some other programs that use Alt+l as a keyboard shortcut and how: https://defkey.com/what-means/alt-l

The only alternative — and I'm not suggesting it's any better, only different — is to piggy back off the keyboard shortcuts we already have. So we have something close to the following:

⇧ / ⇩: Navigate between items in the list.
⇦ / ⇨: Collapse or expand nested items or lists.

It could be extended too:

⌘ + ⇦ / ⌘ + ⇨: This is equivalent of Home/End. Navigation to top and bottom of list.

⌘ + Shift + ⇦ / ⌘ + Shift + ⇨: Collapse or expand items or lists except focussed.

⌘ + Shift + ⇧ / ⌘ + Shift + ⇩: Expand/collapse all?

@andrewserong
Copy link
Contributor Author

Thanks for the continued discussion, much appreciated, and it's tricky coming up with a good shortcut!

Just to be sure, is there a conflict in making ⌥L a global shortcut to collapse all other groups than the selected one, regardless of where focus is?

The conflict is that ⌥L outputs a character when focus is within a RichText field, (screenshot in: #59978 (comment)).

⌘ + Shift + ⇦ / ⌘ + Shift + ⇨: Collapse or expand items or lists except focussed.
⌘ + Shift + ⇧ / ⌘ + Shift + ⇩: Expand/collapse all?

Unfortunately, these too conflict with navigating around text content within a RichText field, as those keyboard shortcuts move to the beginning and end of a line while selecting text content, or to the top or bottom of an area while selecting text content. Also, since we allow multiple block selection in the list view, ⌘ + Shift + ⇧ might be expected to select multiple blocks instead of performing a collapse/expand 🤔


So, currently the main conflict we're encountering is what happens when you're within a Paragraph or Heading block (or similar) within the editor canvas and expect the keyboard shortcut to perform an action solely within the list view.

A few potential ideas:

  • We go with ⌥L, but disallow the keyboard shortcut to work if the user is within a RichText field, or:
  • We go with ⌥L, but only allow it within the list view (from earlier testing on this PR, it seemed it was a bit confusing that focus had to be within the list view?)
  • We try coming up with a different keyboard shortcut that doesn't conflict with anything else (this is proving challenging!)

I might have a go at "We go with ⌥L, but disallow the keyboard shortcut to work if the user is within a RichText field", unless anyone feels strongly about other options or ideas?

@ramonjd
Copy link
Member

ramonjd commented Mar 25, 2024

I might have a go at "We go with ⌥L, but disallow the keyboard shortcut to work if the user is within a RichText field", unless anyone feels strongly about other options or ideas?

Sounds good, thanks for digging into this!

@andrewserong
Copy link
Contributor Author

Update: that seems to have been pretty straightforward. In 0dc613b, I'm skipping the keyboard shortcut if we're in a text field / contenteditable in the editor canvas. And in 150b57e I've added some test coverage for the private action and selector.

I believe this should be ready for review. Overall, I think ⌥L is probably a decent shortcut to go for, for now, and it's a simple code change to change it after the fact if a better alternative presents itself.

Copy link
Contributor

@jasmussen jasmussen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conflict is that ⌥L outputs a character when focus is within a RichText field

I'm skipping the keyboard shortcut if we're in a text field / contenteditable in the editor canvas.

This is working remarkably well. Thank you! 👍 👍 from this angle.

@richtabor
Copy link
Member

Good stuff.

  1. My first expectation when testing was that it would both close and re-open if engaged on the same list view item. Not sure if anyone else shares that, but otherwise I have to manually open the list with the caret icon, or click on the canvas again, to re-open.
  2. I too ran into the ¬ RichText shortcut issue.
@andrewserong
Copy link
Contributor Author

Thanks folks!

@richtabor are either of those issues blockers to landing for you? Happy to hold off on merging, if so.

My first expectation when testing was that it would both close and re-open if engaged on the same list view item.

I was thinking of looking into the re-opening behaviour in a follow-up as it's a little more complex to figure out when to reliably re-open, so I thought it might be easier in a separate PR.

I too ran into the ¬ RichText shortcut issue.

Unfortunately I think the only way around that one would be for us to come up with a different keyboard shortcut altogether to avoid the collision. Our options here, I believe, are to go with ⌥L for now and potentially change the shortcut further down the road if a better one reveals itself to us, or hold off while we explore options.

I'm leaning a bit toward landing this in its current form and then iterating, but I don't feel strongly about it 🙂

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a passing ✅

Nested lists are collapsing as described for me. Alt + L is as good as any I guess, pending decision on Rich's feedback.

Also, obligatory video:

2024-03-26.09.49.28.mp4
@richtabor
Copy link
Member

I was thinking of looking into the re-opening behaviour in a follow-up as it's a little more complex to figure out when to reliably re-open, so I thought it might be easier in a separate PR.

Sounds good.

I too ran into the ¬ RichText shortcut issue.
Unfortunately I think the only way around that one would be for us to come up with a different keyboard shortcut altogether to avoid the collision. Our options here, I believe, are to go with ⌥L for now and potentially change the shortcut further down the road if a better one reveals itself to us, or hold off while we explore options.

This particular issue will certainly come up. I noticed that Figma's command only triggers when a group is selected (rather than any child groups/items). Is that something we want to consider here? That would resolve this issue as well.

@andrewserong
Copy link
Contributor Author

andrewserong commented Mar 26, 2024

This particular issue will certainly come up. I noticed that Figma's command only triggers when a group is selected (rather than any child groups/items). Is that something we want to consider here? That would resolve this issue as well.

I'm not sure how it would resolve the issue, as we're already skipping the shortcut when we're in a text field (i.e. any block with a rich text field). The ¬ character being output is just standard keyboard behaviour on a Mac when a user presses ⌥L in any text field, so we don't want to prevent that from happening, it's just that folks will see that character being output when in a paragraph or heading block (in the editor canvas) and going to use this shortcut. The current state of this PR is that when that character is output, we skip the shortcut from firing. I suppose in this respect it's a bit like the CMD+K behaviour where we only allow it to open the command palette when a user isn't somewhere where they'd be editing a link?

@andrewserong
Copy link
Contributor Author

Just double checked how it appears that things are handled in Figma, and it seems to use a similar approach to this one of skipping the shortcut if you're in a text field. I.e. if I'm editing a text area within a frame, or the text area within the layers panel, then the shortcut is skipped and ¬ is output. If you're not in a text area, then the shortcut appears to fire:

2024-03-27.15.28.37.mp4

I think the main reason it's more visible in Gutenberg is that Figma being more design-based, you have to go to more effort in order to be actively editing within a text field.

Since the behaviour right now is a parallel to Figma's, and there are a couple of approving reviews, I'll merge this PR in. Ideas for next steps:

  • Explore the inverse of this shortcut so that we can press the shortcut again to toggle to expand the tree
  • If the output of ¬ when in a text field is too intrusive, let's explore alternative keyboard shortcuts

Thanks again for the ideas and discussion, everyone! And of course, if the behaviour of this keyboard shortcut feels off in trunk, it's a fairly simple revert if we decide we need to backtrack.

@andrewserong andrewserong merged commit e30a12b into trunk Mar 27, 2024
59 checks passed
@andrewserong andrewserong deleted the add/list-view-keyboard-shortcut-to-collapse-list-view-items branch March 27, 2024 04:58
@github-actions github-actions bot added this to the Gutenberg 18.1 milestone Mar 27, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Mar 27, 2024
…an the focused item (WordPress#59978)

* List View: Add keyboard shortcut to collapse list view items other than the focused item

* Remove keyboard shortcut info from customize-widgets as there is no list view in that context

* Add e2e test coverage

* Try adding some state to get it working from the editor canvas

* Skip keyboard shortcut in the editor canvas if the event is fired from a text field

* Add a few tests

Unlinked contributors: jarekmorawski.

Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
@richtabor
Copy link
Member

it's just that folks will see that character being output when in a paragraph or heading block (in the editor canvas) and going to use this shortcut.

It's just much more visible in the editor. This unexpected behavior will likely deter folks from utilizing the shortcut liberally, as it creates more work if that character is applied—especially if I failed to notice it. Just noting this.

@andrewserong
Copy link
Contributor Author

It's just much more visible in the editor. This unexpected behavior will likely deter folks from utilizing the shortcut liberally, as it creates more work if that character is applied—especially if I failed to notice it. Just noting this.

Totally agree! Let me know if you can think of any alternate keyboard shortcuts or other avenues to explore. Happy to continue hacking on subsequent PRs 🙂

cbravobernal pushed a commit to garridinsi/gutenberg that referenced this pull request Apr 9, 2024
…an the focused item (WordPress#59978)

* List View: Add keyboard shortcut to collapse list view items other than the focused item

* Remove keyboard shortcut info from customize-widgets as there is no list view in that context

* Add e2e test coverage

* Try adding some state to get it working from the editor canvas

* Skip keyboard shortcut in the editor canvas if the event is fired from a text field

* Add a few tests

Unlinked contributors: jarekmorawski.

Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] List View Menu item in the top toolbar to select blocks from a list of links. [Type] Enhancement A suggestion for improvement.
6 participants