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

Add focus mode for Navigation Menus #39286

Merged
merged 4 commits into from
Jun 16, 2023

Conversation

getdave
Copy link
Contributor

@getdave getdave commented Mar 8, 2022

What

Adds a focus mode to Navigations. Can be accessed via Browse Mode or directly via URL.

Also refactors the Site Editor code to enable this.

Part of #50396.

Why

In #37950 we learnt that a "focus mode" for editing Navigation Menus in isolation could be useful.

This PR implements that experience allowing you to edit a menu's items in the block editor canvas.

Note that because a Navigation Menu can be assigned to multiple blocks, this experience must necessarily be presentationally agonistic (i.e. it's intended to focus more on manipulating the menu items rather than the specific Navigation block instance).

How

Extends the existing infrastructure around Template Parts to also handle Navigation Menu entities. This requires some interesting "hacks" such as using a "ghost" Navigation block to provide the editing context. I anticipate these will be removed in future in favour of a more unified experience but this will be a wider refactor and much more invovled.

Closes #37950.

Testing Instructions

  • Create a new Navigation Menus (with some items) using the Nav block.
  • Load the Site Editor and open Browse Mode.
  • Click Navigation and then select one of your menus.
  • See the editor window change to a isolated version of the block.
  • Click on the editor to enter focus mode.
  • See that the Nav block is there but it's locked down and doesn't show any controls.
  • Verify you can still access list view editing mode on the Navigation block.
  • Make some changes to the menu items and save.
  • Open Browse Mode again and see changes reflected there.

Try this with some Themes with Global Styles which effect the styling of the Navigation. You should see the styles inherited in the focus mode.

Todo

  • Refactor around bias toward templates and template parts.
  • Add spacing/padding around Navigation block when not in full "focus" mode (i.e. when browsing via Navigation in Browse Mode).
  • Restrict block editor to only allow the current root block (i.e. the Navigation block) when in focus mode for the wp_navigation entity.
  • Remove controls coming from block supports on the Navigation block. Note this will require adding a hook which adds an "Alignment" control to the Nav block just for focus mode.
  • Consider adding focus as one of the editor modes. We can then toggle this when entering focus mode and allow us to conditionalise various things about the UI based on whether it is active.

Screenshots

Screen.Capture.on.2023-06-12.at.13-53-56.mp4

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).
  • I've updated related schemas if appropriate.

@getdave getdave added [Block] Navigation Affects the Navigation Block [Type] Experimental Experimental feature or API. labels Mar 8, 2022
@getdave getdave self-assigned this Mar 8, 2022
@getdave getdave changed the title Navigation menu focus mode editor experiment [Experiment] Navigation menu focus mode editor Mar 8, 2022
@github-actions
Copy link

github-actions bot commented Mar 8, 2022

Size Change: +1.14 kB (0%)

Total Size: 1.4 MB

Filename Size Change
build/block-library/index.min.js 201 kB +42 B (0%)
build/edit-site/index.min.js 70.7 kB +1.04 kB (+1%)
build/edit-site/style-rtl.css 11.6 kB +26 B (0%)
build/edit-site/style.css 11.6 kB +26 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.29 kB
build/autop/index.min.js 2.1 kB
build/blob/index.min.js 451 B
build/block-directory/index.min.js 7.05 kB
build/block-directory/style-rtl.css 1.02 kB
build/block-directory/style.css 1.02 kB
build/block-editor/content-rtl.css 4.22 kB
build/block-editor/content.css 4.22 kB
build/block-editor/default-editor-styles-rtl.css 381 B
build/block-editor/default-editor-styles.css 381 B
build/block-editor/index.min.js 196 kB
build/block-editor/style-rtl.css 14.9 kB
build/block-editor/style.css 14.9 kB
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/audio/theme-rtl.css 126 B
build/block-library/blocks/audio/theme.css 126 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 584 B
build/block-library/blocks/button/editor.css 582 B
build/block-library/blocks/button/style-rtl.css 624 B
build/block-library/blocks/button/style.css 623 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 409 B
build/block-library/blocks/columns/style.css 409 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/cover/style-rtl.css 1.61 kB
build/block-library/blocks/cover/style.css 1.6 kB
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 159 B
build/block-library/blocks/details/style.css 159 B
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 126 B
build/block-library/blocks/embed/theme.css 126 B
build/block-library/blocks/file/editor-rtl.css 316 B
build/block-library/blocks/file/editor.css 316 B
build/block-library/blocks/file/interactivity.min.js 395 B
build/block-library/blocks/file/style-rtl.css 269 B
build/block-library/blocks/file/style.css 270 B
build/block-library/blocks/freeform/editor-rtl.css 2.58 kB
build/block-library/blocks/freeform/editor.css 2.58 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.53 kB
build/block-library/blocks/gallery/style.css 1.53 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 654 B
build/block-library/blocks/group/editor.css 654 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 76 B
build/block-library/blocks/heading/style.css 76 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 834 B
build/block-library/blocks/image/editor.css 833 B
build/block-library/blocks/image/interactivity.min.js 799 B
build/block-library/blocks/image/style-rtl.css 1.11 kB
build/block-library/blocks/image/style.css 1.11 kB
build/block-library/blocks/image/theme-rtl.css 126 B
build/block-library/blocks/image/theme.css 126 B
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 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 507 B
build/block-library/blocks/media-text/style.css 505 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 712 B
build/block-library/blocks/navigation-link/editor.css 711 B
build/block-library/blocks/navigation-link/style-rtl.css 115 B
build/block-library/blocks/navigation-link/style.css 115 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.35 kB
build/block-library/blocks/navigation/editor.css 2.36 kB
build/block-library/blocks/navigation/interactivity.min.js 978 B
build/block-library/blocks/navigation/style-rtl.css 2.21 kB
build/block-library/blocks/navigation/style.css 2.2 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 401 B
build/block-library/blocks/page-list/editor.css 401 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 174 B
build/block-library/blocks/paragraph/editor.css 174 B
build/block-library/blocks/paragraph/style-rtl.css 279 B
build/block-library/blocks/paragraph/style.css 281 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-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 588 B
build/block-library/blocks/post-featured-image/editor.css 586 B
build/block-library/blocks/post-featured-image/style-rtl.css 319 B
build/block-library/blocks/post-featured-image/style.css 319 B
build/block-library/blocks/post-navigation-link/style-rtl.css 153 B
build/block-library/blocks/post-navigation-link/style.css 153 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 314 B
build/block-library/blocks/post-template/style.css 314 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 103 B
build/block-library/blocks/preformatted/style.css 103 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 335 B
build/block-library/blocks/pullquote/style.css 335 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 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 450 B
build/block-library/blocks/query/editor.css 449 B
build/block-library/blocks/quote/style-rtl.css 222 B
build/block-library/blocks/quote/style.css 222 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 132 B
build/block-library/blocks/read-more/style.css 132 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 178 B
build/block-library/blocks/search/editor.css 178 B
build/block-library/blocks/search/style-rtl.css 587 B
build/block-library/blocks/search/style.css 584 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 531 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 234 B
build/block-library/blocks/separator/style.css 234 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 203 B
build/block-library/blocks/site-logo/style.css 203 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/editor-rtl.css 674 B
build/block-library/blocks/social-links/editor.css 673 B
build/block-library/blocks/social-links/style-rtl.css 1.43 kB
build/block-library/blocks/social-links/style.css 1.42 kB
build/block-library/blocks/spacer/editor-rtl.css 348 B
build/block-library/blocks/spacer/editor.css 348 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 433 B
build/block-library/blocks/table/editor.css 433 B
build/block-library/blocks/table/style-rtl.css 645 B
build/block-library/blocks/table/style.css 644 B
build/block-library/blocks/table/theme-rtl.css 146 B
build/block-library/blocks/table/theme.css 146 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/template-part/editor-rtl.css 403 B
build/block-library/blocks/template-part/editor.css 403 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 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 174 B
build/block-library/blocks/video/style.css 174 B
build/block-library/blocks/video/theme-rtl.css 126 B
build/block-library/blocks/video/theme.css 126 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.1 kB
build/block-library/common.css 1.1 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 12.2 kB
build/block-library/editor.css 12.1 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/interactivity/runtime.min.js 2.71 kB
build/block-library/interactivity/vendors.min.js 8.2 kB
build/block-library/reset-rtl.css 478 B
build/block-library/reset.css 478 B
build/block-library/style-rtl.css 13.3 kB
build/block-library/style.css 13.3 kB
build/block-library/theme-rtl.css 686 B
build/block-library/theme.css 691 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 50.8 kB
build/commands/index.min.js 14.9 kB
build/commands/style-rtl.css 827 B
build/commands/style.css 827 B
build/components/index.min.js 231 kB
build/components/style-rtl.css 11.8 kB
build/components/style.css 11.8 kB
build/compose/index.min.js 12.1 kB
build/core-commands/index.min.js 1.77 kB
build/core-data/index.min.js 15.7 kB
build/customize-widgets/index.min.js 12 kB
build/customize-widgets/style-rtl.css 1.38 kB
build/customize-widgets/style.css 1.38 kB
build/data-controls/index.min.js 640 B
build/data/index.min.js 8.3 kB
build/date/index.min.js 40.4 kB
build/deprecated/index.min.js 451 B
build/dom-ready/index.min.js 324 B
build/dom/index.min.js 4.63 kB
build/edit-post/classic-rtl.css 544 B
build/edit-post/classic.css 545 B
build/edit-post/index.min.js 34.1 kB
build/edit-post/style-rtl.css 7.58 kB
build/edit-post/style.css 7.57 kB
build/edit-widgets/index.min.js 16.8 kB
build/edit-widgets/style-rtl.css 4.53 kB
build/edit-widgets/style.css 4.53 kB
build/editor/index.min.js 44.7 kB
build/editor/style-rtl.css 3.54 kB
build/editor/style.css 3.53 kB
build/element/index.min.js 4.8 kB
build/escape-html/index.min.js 537 B
build/format-library/index.min.js 7.57 kB
build/format-library/style-rtl.css 554 B
build/format-library/style.css 553 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/is-shallow-equal/index.min.js 527 B
build/keyboard-shortcuts/index.min.js 1.71 kB
build/keycodes/index.min.js 1.84 kB
build/list-reusable-blocks/index.min.js 2.13 kB
build/list-reusable-blocks/style-rtl.css 836 B
build/list-reusable-blocks/style.css 836 B
build/media-utils/index.min.js 2.9 kB
build/notices/index.min.js 948 B
build/plugins/index.min.js 1.84 kB
build/preferences-persistence/index.min.js 1.84 kB
build/preferences/index.min.js 1.24 kB
build/primitives/index.min.js 941 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 939 B
build/react-i18n/index.min.js 696 B
build/react-refresh-entry/index.min.js 8.44 kB
build/react-refresh-runtime/index.min.js 7.31 kB
build/redux-routine/index.min.js 2.7 kB
build/reusable-blocks/index.min.js 2.21 kB
build/reusable-blocks/style-rtl.css 243 B
build/reusable-blocks/style.css 243 B
build/rich-text/index.min.js 10.7 kB
build/router/index.min.js 1.77 kB
build/server-side-render/index.min.js 2.02 kB
build/shortcode/index.min.js 1.39 kB
build/style-engine/index.min.js 1.42 kB
build/token-list/index.min.js 582 B
build/url/index.min.js 3.57 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 1.04 kB
build/warning/index.min.js 268 B
build/widgets/index.min.js 7.16 kB
build/widgets/style-rtl.css 1.15 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.02 kB

compressed-size-action

@getdave getdave mentioned this pull request Mar 9, 2022
41 tasks
@paaljoachim
Copy link
Contributor

paaljoachim commented Mar 9, 2022

Exploring...
Installed the Gutenberg PR.
Made sure to save the Navigation.
Went to the top/parent Navigation block. (Not entities inside of it.)
Clicked the 3 dot menu.
Noticed down the list a "Edit Header navigation" and selected it.

Screenshot 2022-03-09 at 22 38 13

Came into focused mode.
Screenshot 2022-03-09 at 22 38 24

My initial reaction is that this is a very hidden approach to adjusting the Navigation. It should be much more open approach to handling the navigation entities/elements/links. This is not a good approach to use for adjusting the navigation. As it needs to be much more visible when the Navigation block is selected.

List view
List view which is a good place as it is a current method more and more users will need to get used to to get an overview of the layout. Drilling down into blocks and adjusting the Navigation directly in List view would be an interesting approach.

Settings Sidebar.
Could also be an interesting way. As it uses the existing method of going to the sidebar settings panels to adjust aspects of a block. In this case a full Navigation drag and drop similar to the classic Navigation screen. (Could perhaps be a bit tight on the space.)

#38600 (comment)
Has a Navigation icon below the W icon. One clicks to open the Navigation.

I made a video:
https://youtu.be/qFebtfHZJLU

@getdave
Copy link
Contributor Author

getdave commented Mar 10, 2022

Thanks for taking the time to provide feedback @paaljoachim 👏 🙇‍♂️

This is not a good approach to use for adjusting the navigation

I'd like to challenge that a little. My understanding is that your argument is based on the fact that currently the focus mode is a little hard to discover. Am I right? If so, I agree with that - perhaps the same could be said of all "focus" modes (including Template Part editing).

However, just because it's hidden now, does not mean we could not easily expose a more convenient method to access it directly from the block.

The key benefits of a focus mode are:

  • ability to edit the menu using the familiar direct-manipulation experience afforded by blocks
  • allows access to the inner blocks of the Navigation Menu (this has been requested many times since 5.9) - note that usually these are not available because the Navigation block uses ref to fetch the items from a custom post.
  • allows user to edit a menu which may not be easy to manipulate within the context of the post/page/site - for example if the menu is set to be in "hamburger" (mobile) mode that you cannot see the items to edit. Being able to drop into focus mode and make changes to the structure is highly valuable.

I appreciate this exploration is extremely rough around the edges. However, I'm keen that we don't prematurely dismiss this approach given the value I think it might afford for users.

What do you think?

List view which is a good place as it is a current method more and more users will need to get used to to get an overview of the layout

There is a good argument that a list view based approach is a good idea.

However, I'm concerned that it's not the ideal environment for direct manupulation and we're going to end up having to duplicate a lot of the functionality we get from blocks within the editor canvas (e.g. styling, text label manipulation, block attribute adjustment...etc). I fear we may bloat the list view if we tried to add all these features. To me we'd be better served to reuse the existing canvas-based block tooling we have available already. That's where the focus mode comes in.

I'll also add that I don't see focus mode and sidebar mode as being mutually exclusive (neither does @mtias). They can be complementary.

@paaljoachim
Copy link
Contributor

Hey Dave

I see all focus modes as hidden modes of editing (Except the create a template focus mode). The more direct visible editing we have the better. As it shows it more openly how one would go about editing.

Focus mode. Initial view.

  • Takes the user away from the regular Gutenberg canvas.
  • Is somewhat complementary to regular edit a block in the Gutenberg canvas.
  • To me it feels like focus mode might bring in additional editing capabilities. Which can not so easily be added to the Gutenberg canvas (This feeling might be wrong.)
  • I feel that focus mode could instead stay within the regular Gutenberg canvas.

(The above is my impression with a few toes in the water so to speak.)

I appreciate this exploration is extremely rough around the edges. However, I'm keen that we don't prematurely dismiss this approach given the value I think it might afford for users.

However, just because it's hidden now, does not mean we could not easily expose a more convenient method to access it directly from the block.

Good point! Improving Focus mode visibility will be helpful. My feedback is based on the experience of focus mode up til this point.

What do you think?

I think that we/I need to look at Focus mode and how we can in general improve this feature.


When adding the possibility of using List view to manipulate the Navigation. I could see in the back of my mind that List view would be too limited to all that is needed. Having a separate screen of some kind is still likely needed.

I'll also add that I don't see focus mode and sidebar mode as being mutually exclusive (#36667 (comment)). They can be complementary.

Your various comments swayed me Dave.
It seems that focus mode and a sidebar settings panel is the way to go.

@getdave getdave changed the title [Experiment] Navigation menu focus mode editor [Experiment] Navigation Menu "focus mode" Apr 26, 2022
@getdave getdave changed the title [Experiment] Navigation Menu "focus mode" [Experiment] Focus mode editor for Navigation Menus Apr 26, 2022
@getdave getdave changed the title [Experiment] Focus mode editor for Navigation Menus Isolated editor (focus mode) for Navigation Menus May 11, 2023
@getdave getdave mentioned this pull request May 11, 2023
17 tasks
@jasmussen
Copy link
Contributor

This is cool! But we actually need this for every block, not just navigation. The ellipsis also feels like the right place to add this option, because it can indeed be block agnostic.

The main challenge I see there is that the ellipsis menu is already very long, and adding more options to it is tricky. I don't know if this is a blocker, but I'd love input from @jameskoster and @richtabor as well. Some questions to ponder:

  • Should the label change, something "Edit isolated"? "Edit alone"? "Edit in isolation"?
  • Should there be an edit icon in the menuy? Perhaps the edit-small?
  • Do we need for nested menus to land first, so the ellipsis menu doesn't grow too long, or can it accommodate this one?

Thanks Dave, this is sweet stuff.

@getdave
Copy link
Contributor Author

getdave commented May 11, 2023

But we actually need this for every block, not just navigation.

Interesting. Bear in mind this example is designed to sync with the nav item entities. Whereas for most other blocks this would just be standard inner blocks. We could adapt it to make it more flexible though.

@jameskoster
Copy link
Contributor

As I noted in #50396 (comment), this experience can be a bit strange given the Navigation styles and settings cannot be included in focus mode. Seeing a horizontal menu on the canvas which jumps to vertical orientation when I click "Edit" is surprising. It kind of suggests I'm editing something else. I know this isn't trivial to fix, but it does concern me a bit about merging this.

@jasmussen if we didn't want to clog up the ellipsis menu, we might add an "Edit" item to the toolbar, like template parts:

Screenshot 2023-05-11 at 19 06 59

@getdave
Copy link
Contributor Author

getdave commented May 11, 2023

I agree we shouldn't be merging this as is. It's still Draft after all 😄

But...it would be good to outline some of the problems/concerns like you have done here @jameskoster. Thank you.

@jasmussen
Copy link
Contributor

if we didn't want to clog up the ellipsis menu, we might add an "Edit" item to the toolbar, like template parts:

I do like that edit button. But juxtaposing your note (styles inside the container vs. outside) and my notes from previous conversations that we should be leveraging focus mod wherever possible, I wonder if that Edit pattern works across all containers?

@getdave
Copy link
Contributor Author

getdave commented May 15, 2023

Question: what is the objective of focus mode?

Is it:

  1. Ability to edit the menu items in isolation from any specific Nav block?
  2. Ability to edit a specific Navigation block (along with it's items) in a focused editor (i.e. without surrounding blocks getting in the way)?

If it's the later then we should change the approach from what we've done in this PR.

@jasmussen
Copy link
Contributor

The objective of focus mode in general, and speaking here outside of just its navigation use case, is to let you focus on just the contents of this one template part, or group, or pattern, or piece of content. It's the benefit of the reduced nesting, fewer layers to click through, that just makes it overall a more simple editing experience. And this simpler editing experience can benefit all containers, as noted.

For the navigation, it may be worth connecting dots to #50396 (comment) which features among other things, this mockup:

Multiple menus, and the menu is complex

The user experience is mean to be exactly the same as accessing template parts in the site view. GIF:

tps

That is — you just edit the navigtion in isolation. I understand that @jameskoster's comments are appropriate — the navigation might be collapse to a burger inside a template part, but not if edited directly. I still think the flow is valid.

Does that answer your questions?

@getdave
Copy link
Contributor Author

getdave commented Jun 15, 2023

...not edit the whole block.

I sense the tension here comes from the fact that you can see the wrapping (Navigation) block in the UI? Template Parts and Reusable Blocks don't show the wrapping block in focus mode. However the Nav block is unique because we need to show the list view sidebar and basic layout.

If we could have "ghost" blocks that are:

  • don't display toolbars or show up in list views.
  • not serialized

...then we could achieve the same type of thing. Using the Nav block does allow us to ensure that the behaviour is consistent though.

@jasmussen
Copy link
Contributor

Taking this for a spin, GIF:

nav focus

Lots of thoughts, not all related to this PR but I'll note which ones probably are.

The fact that the Back button shows the tooltip when it receives focus is incredibly jarring. I'd love for us to remove the tooltip from those buttons entirely. Visually it is clearly a back button, and for screen readers, the aria-label will read aloud.

The ellipsis menu with rename and duplicate are great. It would've been nice if the rename option set focus on the input field, just like the Pages > "Add page" dialog does.

Screenshot 2023-06-15 at 10 55 08

Should that same "Add page" dialog be available in navigation menus, with a plus here, next to the ellipsis?

Screenshot 2023-06-15 at 10 56 32

I would presume to add a page, and add it to the same menu.

Good to fix in this PR: Regardless of plus, we need an Edit icon to edit the particular menu, just like we have an edit button for templates:

Screenshot 2023-06-15 at 10 57 18

The ability to click the preview to edit is a bonus, but for anything that's editable there has to always be the edit button too.

I realize that 3 icon buttons (Add page, edit, ellipsis) might be a lot, but I believe that @jameskoster has some designs that manages to balance that.

This is the main focus mode for editing a navigation:

Screenshot 2023-06-15 at 10 58 36

Good to fix in this PR: We should use the navigation icon in the document title, instead of the layout icon, lest you might think you're editing a template part.

I think the larges open question that exists is the existential one: the navigation you edit here will not always look the same as it will look on your website, because on your website it might be styled locally in the template part or template. I would love for us to think long term on whether it would be possible to reapply some of those styles in this case (style providers, local, global, etc). But I also still think we should land this:

  • Having a bespoke navigation section is an incredibly useful way to surface how many navigation menus you have, letting you manage them.
  • It isn't clear that the potential visual disconnect is a problem, and making light-weight edits here is still useful.

If we land this and find that it simply doesn't work, we can lean into the Template Parts aspect, where navigation items can be surfaced in the inspector, #51492, and make the Navigation section be more of a "Templates > Manage all templates"-like list view. But it feels too early to make that call. And in the mean time, we can do more to make the discrepancy clear.

Good to fix in this PR: for example we can add help text here:

Screenshot 2023-06-15 at 11 01 23

Instead of the text:

Navigation menus are a curated collection of blocks that allow visitors to get around your site.

We could have:

This is your [Footer] navigation menu. 

You can edit this menu here, but be aware that visual styles might be applied separately in templates or template parts, so the preview shown here can be incomplete.

We can even show a subheading and help-text in the focus-mode canvas just like we do for the Style Book (e.g. Headings, etc).

@getdave
Copy link
Contributor Author

getdave commented Jun 15, 2023

  • we need an Edit icon to edit the particular menu, just like we have an edit button for templates:
  • We should use the navigation icon in the document title, instead of the layout icon, lest you might think you're editing a template part.
  • We can add help text here:
Screenshot 2023-06-15 at 11 01 23

Instead of the text:

Navigation menus are a curated collection of blocks that allow visitors to get around your site.

We could have:

This is your [Footer] navigation menu. 

You can edit this menu here, but be aware that visual styles might be applied separately in templates or template parts, so the preview shown here can be incomplete.

We can even show a subheading and help-text in the focus-mode canvas just like we do for the Style Book (e.g. Headings, etc).

@jameskoster
Copy link
Contributor

A couple of small obversations additional to Joen's excellent feedback:

In the edit view, the main Inserter seems to be empty. Searching returns nothing.

I see a "Template" tab which doesn't really make sense. Should this be "Navigation"?

Appreciate this will be a separate discussion, but that tab doesn't seem to have much use here, except for the Revisions link. It almost feels like we could remove the "Block" tab and place its current contents to the "Template" tab. Then you could remove the Navigation block in List View as well, which could be nice as it doesn't seem to serve much purpose here.

I digress. When you enter Revisions for a menu, there is a "← Go to editor" link, which suggests you'll be returned to the edit view on click. But instead it takes you to the menu edit UI in wp-admin. Could this be fixed?

The delete menu modal is different to the one you find when deleting a page. It would be good to align and ideally reuse the same component so we can circle back and update all at once.

There's a small quirk in the drilldown when you only have on menu. Clicking Navigation at the root takes you directly to the menu. But clicking Back then takes you to the Navigation panel which feels a bit disorienting:

drilldown.mp4

Ellipsis icons are mis-aligned:

Screenshot 2023-06-15 at 11 38 07

Ideally the buttons here should match the other sidebar menu items in terms of dimensions etc.

Finally, I noticed that clicking a page takes you to the details panel for that page. It's possible I missed something, but iirc that functionality is going to be removed?

Fixing unlocking

Avoid unnecessarily effectful code

Fix bug with persistent Nav block locking

Reinstate effect to limit calls to selectBlock

Reinstate effect to run selectively

Isolate Nav specific code

Refactor settings to hook

Isolate Editor Canvas to component

Extract mode statuses to hook

Colocate editor canvas dependencies

Remove requirement for Nav hook to return data

Extract entire canvas to component

Get blocks directly from the store

Use factory to provide default editor component

Extract independent components for default and wp_navigation

Remove template dep from Navigation focus hook

Delete redundant hook

Remove need for settings prop

Extract hooks to files

Export boolean to avoid render

Remove redundant prop and var

Extract Site Editor Canvas component to file

Extract factory to file

Remove need to pass props to abstract component

Improve abstract component and factory naming

Improve usage of constants

Be explicit about entity mapping in factory

Remove templateType prop from SiteEditorCanvas component

Improve variable naming

Use more performant selector

Improve documenting rule for showing appender

Move Navigation specific editor settings to relevant provider

Remove useSiteEditorMode hook

See #39286 (comment)

Reintstate bug fix with comment

Fix error in rebase

Add edit button

Use Navigation icon and label

Use correct labels
@scruffian scruffian force-pushed the try/navigation-menu-focus-mode-experiment branch from b9dc123 to 04e1104 Compare June 15, 2023 12:40
@getdave
Copy link
Contributor Author

getdave commented Jun 15, 2023

@jameskoster thanks for feedback. Here are the actionable tasls I picked out:

  • In the edit view, the main Inserter seems to be empty. Searching returns nothing.
  • I see a "Template" tab which doesn't really make sense. Should this be "Navigation"?
  • that tab [the one mentioned above] doesn't seem to have much use here, except for the Revisions link. It almost feels like we could remove the "Block" tab and place its current contents to the "Template" tab.
  • Remove the Navigation block in List View as well, which could be nice as it doesn't seem to serve much purpose here. If a block is in the canvas we don't currently have a means to hide it from the List View. If this "ghost" Nav block remains as a concept/requirement then it might be worth investing time in creating an API that allows blocks to exist but not show up in the UI. It's beyond the scope of what I can achieve here though.
  • When you enter Revisions for a menu, there is a "← Go to editor" link, which suggests you'll be returned to the edit view on click. But instead it takes you to the menu edit UI in wp-admin.
  • The delete menu modal is different to the one you find when deleting a page. It would be good to align and ideally reuse the same component so we can circle back and update all at once. That will need to be a separate Issue from this PR.
  • There's a small quirk in the drilldown when you only have on menu. Clicking Navigation at the root takes you directly to the menu. But clicking Back then takes you to the Navigation panel which feels a bit disorienting: This is a known issue with the Navigator component. It happens elsewhere as well. It's beyond the scope of what we can tackle here but we do need a separate Issue to address this.
  • Ellipsis icons are mis-aligned:
  • Clicking a page takes you to the details panel for that page. It's possible I missed something, but iirc that functionality is going to be removed? Won't fix. Being handled in Navigation on Browse Mode: Move the action to the leaf menu #50843

that tab [the one mentioned above] doesn't seem to have much use here, except for the Revisions link. It almost feels like we could remove the "Block" tab and place its current contents to the "Template" tab.

It seems like this comment also applies to Template Parts. Why specifically does this become a problem for Navigation? The reason I ask is that I'm keen to avoid too many branches in the code when there might be underlying problems or concepts that we need to reveal.

@getdave
Copy link
Contributor Author

getdave commented Jun 15, 2023

I've been looking into why the inserter is empty.

Firstly this is due to the templateLock: 'insert' so we'll need to look into that one.

If we disable that one for testing however, we still get what I assume would be unexpected behaviour, in that when the Nav block is focused opening the inserter does not insert blocks into the Nav block but rather into the "next" slot on the canvas.

I think we need to set the block as the root client id.

Ultimately it ends up with a call to wp.data.select('core/block-editor').getInserterItems(rootClientId). It seems that the rootClientId is not set so our items are not filtered as we'd expect.

@jameskoster
Copy link
Contributor

It seems like this comment also applies to Template Parts. Why specifically does this become a problem for Navigation?

Template parts also use this region for actions (clearing customisations, deleting), but you're right... the template part inspector is also a bit weak. Probably fine to look into separately.

This is a known issue with the Navigator component. It happens elsewhere as well. It's beyond the scope of what we can tackle here but we do need a separate Issue to address this.

True. Maybe we can tackle this in #51421.

I've been looking into why the inserter is empty.

I noticed the same thing happens when page editing too, and opened #51538. Feel free to edit / expand context there.

@scruffian
Copy link
Contributor

I think it's important to note that the issue this block lacking its surrounding context when editing in focus mode is the same issue that we have in the post editor - the post editor cannot know whether the post will be viewed in a single template or an archive template for example, so users will face the same potential confustion.

Copy link
Contributor

@scruffian scruffian left a comment

Choose a reason for hiding this comment

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

This is looking really good. There are a few things we still need to look at, but we should do them in a followup, let's merge and iterate.

@scruffian scruffian merged commit e2cfaaa into trunk Jun 16, 2023
@scruffian scruffian deleted the try/navigation-menu-focus-mode-experiment branch June 16, 2023 09:29
@github-actions github-actions bot added this to the Gutenberg 16.1 milestone Jun 16, 2023
@scruffian
Copy link
Contributor

Followups:
#51580
#51581

sethrubenstein pushed a commit to pewresearch/gutenberg that referenced this pull request Jul 13, 2023
* Add new state handlers for setting Nav Menu

Fixing unlocking

Avoid unnecessarily effectful code

Fix bug with persistent Nav block locking

Reinstate effect to limit calls to selectBlock

Reinstate effect to run selectively

Isolate Nav specific code

Refactor settings to hook

Isolate Editor Canvas to component

Extract mode statuses to hook

Colocate editor canvas dependencies

Remove requirement for Nav hook to return data

Extract entire canvas to component

Get blocks directly from the store

Use factory to provide default editor component

Extract independent components for default and wp_navigation

Remove template dep from Navigation focus hook

Delete redundant hook

Remove need for settings prop

Extract hooks to files

Export boolean to avoid render

Remove redundant prop and var

Extract Site Editor Canvas component to file

Extract factory to file

Remove need to pass props to abstract component

Improve abstract component and factory naming

Improve usage of constants

Be explicit about entity mapping in factory

Remove templateType prop from SiteEditorCanvas component

Improve variable naming

Use more performant selector

Improve documenting rule for showing appender

Move Navigation specific editor settings to relevant provider

Remove useSiteEditorMode hook

See WordPress#39286 (comment)

Reintstate bug fix with comment

Fix error in rebase

Add edit button

Use Navigation icon and label

Use correct labels

* Add descriptive text as instructed

See WordPress#39286

* Update edit link for Navigation post type

Fixes revisions link

* Fix PHPCS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Feature] Navigation in Site View Navigation section in the Site Editor when in Site View, offering a way to manage Navigation Menus a [Type] Feature New feature to highlight in changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Navigation Focus Mode: Ability to access/edit Navigation Post items in isolation