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 tree view to the navigation block #35149

Closed

Conversation

adamziel
Copy link
Contributor

@adamziel adamziel commented Sep 27, 2021

Description

Explorations related to #29747

This PR moves the tree view CSS from the edit-navigation package to the navigation block, and exposes them a a "tree view" toggle button. We mostly shuffle existing CSS rules with very little new CSS added. Tree view is an editor-only feature and does not affect site rendering.

Kapture.2021-10-08.at.16.12.19.mp4

(yes, the icon is confusing at the moment)

@adamziel adamziel self-assigned this Sep 27, 2021
@adamziel adamziel changed the title First stab at accordion as navigation block style Add accordion as navigation block style Sep 27, 2021
@adamziel adamziel changed the title Add accordion as navigation block style Accordion as navigation block style Sep 27, 2021
@github-actions
Copy link

github-actions bot commented Sep 27, 2021

Size Change: +1.17 kB (0%)

Total Size: 1.07 MB

Filename Size Change
build/block-library/blocks/navigation/editor-rtl.css 2.28 kB +562 B (+33%) 🚨
build/block-library/blocks/navigation/editor.css 2.29 kB +567 B (+33%) 🚨
build/block-library/blocks/navigation/style-rtl.css 1.63 kB +18 B (+1%)
build/block-library/blocks/navigation/style.css 1.63 kB +15 B (+1%)
build/block-library/editor-rtl.css 10.3 kB +447 B (+5%) 🔍
build/block-library/editor.css 10.3 kB +451 B (+5%) 🔍
build/block-library/index.min.js 147 kB +86 B (0%)
build/block-library/style-rtl.css 10.5 kB +21 B (0%)
build/block-library/style.css 10.5 kB +17 B (0%)
build/edit-navigation/index.min.js 15.4 kB +58 B (0%)
build/edit-navigation/style-rtl.css 3.2 kB -536 B (-14%) 👏
build/edit-navigation/style.css 3.2 kB -540 B (-14%) 👏
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 931 B
build/admin-manifest/index.min.js 1.09 kB
build/annotations/index.min.js 2.7 kB
build/api-fetch/index.min.js 2.21 kB
build/autop/index.min.js 2.08 kB
build/blob/index.min.js 459 B
build/block-directory/index.min.js 6.2 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/default-editor-styles-rtl.css 378 B
build/block-editor/default-editor-styles.css 378 B
build/block-editor/index.min.js 135 kB
build/block-editor/style-rtl.css 13.9 kB
build/block-editor/style.css 13.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 65 B
build/block-library/blocks/archives/style.css 65 B
build/block-library/blocks/audio/editor-rtl.css 58 B
build/block-library/blocks/audio/editor.css 58 B
build/block-library/blocks/audio/style-rtl.css 111 B
build/block-library/blocks/audio/style.css 111 B
build/block-library/blocks/audio/theme-rtl.css 125 B
build/block-library/blocks/audio/theme.css 125 B
build/block-library/blocks/block/editor-rtl.css 161 B
build/block-library/blocks/block/editor.css 161 B
build/block-library/blocks/button/editor-rtl.css 474 B
build/block-library/blocks/button/editor.css 474 B
build/block-library/blocks/button/style-rtl.css 600 B
build/block-library/blocks/button/style.css 600 B
build/block-library/blocks/buttons/editor-rtl.css 315 B
build/block-library/blocks/buttons/editor.css 315 B
build/block-library/blocks/buttons/style-rtl.css 370 B
build/block-library/blocks/buttons/style.css 370 B
build/block-library/blocks/calendar/style-rtl.css 207 B
build/block-library/blocks/calendar/style.css 207 B
build/block-library/blocks/categories/editor-rtl.css 84 B
build/block-library/blocks/categories/editor.css 83 B
build/block-library/blocks/categories/style-rtl.css 79 B
build/block-library/blocks/categories/style.css 79 B
build/block-library/blocks/code/style-rtl.css 90 B
build/block-library/blocks/code/style.css 90 B
build/block-library/blocks/code/theme-rtl.css 131 B
build/block-library/blocks/code/theme.css 131 B
build/block-library/blocks/columns/editor-rtl.css 206 B
build/block-library/blocks/columns/editor.css 205 B
build/block-library/blocks/columns/style-rtl.css 497 B
build/block-library/blocks/columns/style.css 496 B
build/block-library/blocks/cover/editor-rtl.css 666 B
build/block-library/blocks/cover/editor.css 670 B
build/block-library/blocks/cover/style-rtl.css 1.24 kB
build/block-library/blocks/cover/style.css 1.24 kB
build/block-library/blocks/embed/editor-rtl.css 488 B
build/block-library/blocks/embed/editor.css 488 B
build/block-library/blocks/embed/style-rtl.css 417 B
build/block-library/blocks/embed/style.css 417 B
build/block-library/blocks/embed/theme-rtl.css 124 B
build/block-library/blocks/embed/theme.css 124 B
build/block-library/blocks/file/editor-rtl.css 300 B
build/block-library/blocks/file/editor.css 300 B
build/block-library/blocks/file/style-rtl.css 255 B
build/block-library/blocks/file/style.css 255 B
build/block-library/blocks/file/view.min.js 322 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/editor-rtl.css 977 B
build/block-library/blocks/gallery/editor.css 982 B
build/block-library/blocks/gallery/style-rtl.css 1.6 kB
build/block-library/blocks/gallery/style.css 1.59 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 159 B
build/block-library/blocks/group/editor.css 159 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 114 B
build/block-library/blocks/heading/style.css 114 B
build/block-library/blocks/home-link/style-rtl.css 247 B
build/block-library/blocks/home-link/style.css 247 B
build/block-library/blocks/html/editor-rtl.css 332 B
build/block-library/blocks/html/editor.css 333 B
build/block-library/blocks/image/editor-rtl.css 731 B
build/block-library/blocks/image/editor.css 730 B
build/block-library/blocks/image/style-rtl.css 491 B
build/block-library/blocks/image/style.css 494 B
build/block-library/blocks/image/theme-rtl.css 124 B
build/block-library/blocks/image/theme.css 124 B
build/block-library/blocks/latest-comments/style-rtl.css 284 B
build/block-library/blocks/latest-comments/style.css 284 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B
build/block-library/blocks/latest-posts/editor.css 137 B
build/block-library/blocks/latest-posts/style-rtl.css 528 B
build/block-library/blocks/latest-posts/style.css 527 B
build/block-library/blocks/list/style-rtl.css 94 B
build/block-library/blocks/list/style.css 94 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 493 B
build/block-library/blocks/media-text/style.css 490 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 568 B
build/block-library/blocks/navigation-link/editor.css 570 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B
build/block-library/blocks/navigation-link/style.css 94 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 300 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation-submenu/style-rtl.css 195 B
build/block-library/blocks/navigation-submenu/style.css 195 B
build/block-library/blocks/navigation-submenu/view.min.js 343 B
build/block-library/blocks/navigation/view.min.js 2.74 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 198 B
build/block-library/blocks/page-list/style.css 198 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B
build/block-library/blocks/paragraph/editor.css 157 B
build/block-library/blocks/paragraph/style-rtl.css 273 B
build/block-library/blocks/paragraph/style.css 273 B
build/block-library/blocks/post-author/editor-rtl.css 210 B
build/block-library/blocks/post-author/editor.css 210 B
build/block-library/blocks/post-author/style-rtl.css 182 B
build/block-library/blocks/post-author/style.css 181 B
build/block-library/blocks/post-comments-form/style-rtl.css 140 B
build/block-library/blocks/post-comments-form/style.css 140 B
build/block-library/blocks/post-comments/style-rtl.css 360 B
build/block-library/blocks/post-comments/style.css 359 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B
build/block-library/blocks/post-excerpt/editor.css 73 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B
build/block-library/blocks/post-excerpt/style.css 69 B
build/block-library/blocks/post-featured-image/editor-rtl.css 396 B
build/block-library/blocks/post-featured-image/editor.css 397 B
build/block-library/blocks/post-featured-image/style-rtl.css 146 B
build/block-library/blocks/post-featured-image/style.css 146 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 391 B
build/block-library/blocks/post-template/style.css 392 B
build/block-library/blocks/post-terms/style-rtl.css 73 B
build/block-library/blocks/post-terms/style.css 73 B
build/block-library/blocks/post-title/style-rtl.css 60 B
build/block-library/blocks/post-title/style.css 60 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 198 B
build/block-library/blocks/pullquote/editor.css 198 B
build/block-library/blocks/pullquote/style-rtl.css 378 B
build/block-library/blocks/pullquote/style.css 378 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 262 B
build/block-library/blocks/query-pagination/editor.css 255 B
build/block-library/blocks/query-pagination/style-rtl.css 234 B
build/block-library/blocks/query-pagination/style.css 231 B
build/block-library/blocks/query-title/editor-rtl.css 85 B
build/block-library/blocks/query-title/editor.css 85 B
build/block-library/blocks/query/editor-rtl.css 131 B
build/block-library/blocks/query/editor.css 132 B
build/block-library/blocks/quote/style-rtl.css 187 B
build/block-library/blocks/quote/style.css 187 B
build/block-library/blocks/quote/theme-rtl.css 220 B
build/block-library/blocks/quote/theme.css 222 B
build/block-library/blocks/rss/editor-rtl.css 202 B
build/block-library/blocks/rss/editor.css 204 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 165 B
build/block-library/blocks/search/editor.css 165 B
build/block-library/blocks/search/style-rtl.css 374 B
build/block-library/blocks/search/style.css 375 B
build/block-library/blocks/search/theme-rtl.css 64 B
build/block-library/blocks/search/theme.css 64 B
build/block-library/blocks/separator/editor-rtl.css 99 B
build/block-library/blocks/separator/editor.css 99 B
build/block-library/blocks/separator/style-rtl.css 250 B
build/block-library/blocks/separator/style.css 250 B
build/block-library/blocks/separator/theme-rtl.css 172 B
build/block-library/blocks/separator/theme.css 172 B
build/block-library/blocks/shortcode/editor-rtl.css 474 B
build/block-library/blocks/shortcode/editor.css 474 B
build/block-library/blocks/site-logo/editor-rtl.css 769 B
build/block-library/blocks/site-logo/editor.css 769 B
build/block-library/blocks/site-logo/style-rtl.css 165 B
build/block-library/blocks/site-logo/style.css 165 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 84 B
build/block-library/blocks/site-title/editor.css 84 B
build/block-library/blocks/social-link/editor-rtl.css 165 B
build/block-library/blocks/social-link/editor.css 165 B
build/block-library/blocks/social-links/editor-rtl.css 812 B
build/block-library/blocks/social-links/editor.css 811 B
build/block-library/blocks/social-links/style-rtl.css 1.3 kB
build/block-library/blocks/social-links/style.css 1.3 kB
build/block-library/blocks/spacer/editor-rtl.css 307 B
build/block-library/blocks/spacer/editor.css 307 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 471 B
build/block-library/blocks/table/editor.css 472 B
build/block-library/blocks/table/style-rtl.css 481 B
build/block-library/blocks/table/style.css 481 B
build/block-library/blocks/table/theme-rtl.css 188 B
build/block-library/blocks/table/theme.css 188 B
build/block-library/blocks/tag-cloud/style-rtl.css 146 B
build/block-library/blocks/tag-cloud/style.css 146 B
build/block-library/blocks/template-part/editor-rtl.css 636 B
build/block-library/blocks/template-part/editor.css 635 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/editor-rtl.css 90 B
build/block-library/blocks/term-description/editor.css 90 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 87 B
build/block-library/blocks/verse/style.css 87 B
build/block-library/blocks/video/editor-rtl.css 571 B
build/block-library/blocks/video/editor.css 572 B
build/block-library/blocks/video/style-rtl.css 173 B
build/block-library/blocks/video/style.css 173 B
build/block-library/blocks/video/theme-rtl.css 124 B
build/block-library/blocks/video/theme.css 124 B
build/block-library/common-rtl.css 853 B
build/block-library/common.css 849 B
build/block-library/reset-rtl.css 474 B
build/block-library/reset.css 474 B
build/block-library/theme-rtl.css 665 B
build/block-library/theme.css 669 B
build/block-serialization-default-parser/index.min.js 1.09 kB
build/block-serialization-spec-parser/index.min.js 2.79 kB
build/blocks/index.min.js 45.7 kB
build/components/index.min.js 214 kB
build/components/style-rtl.css 15.9 kB
build/components/style.css 15.9 kB
build/compose/index.min.js 10.3 kB
build/core-data/index.min.js 12.4 kB
build/customize-widgets/index.min.js 11.2 kB
build/customize-widgets/style-rtl.css 1.5 kB
build/customize-widgets/style.css 1.49 kB
build/data-controls/index.min.js 614 B
build/data/index.min.js 7.1 kB
build/date/index.min.js 31.5 kB
build/deprecated/index.min.js 428 B
build/dom-ready/index.min.js 304 B
build/dom/index.min.js 4.45 kB
build/edit-post/classic-rtl.css 492 B
build/edit-post/classic.css 494 B
build/edit-post/index.min.js 29.2 kB
build/edit-post/style-rtl.css 7.2 kB
build/edit-post/style.css 7.19 kB
build/edit-site/index.min.js 29.4 kB
build/edit-site/style-rtl.css 5.5 kB
build/edit-site/style.css 5.5 kB
build/edit-widgets/index.min.js 15.7 kB
build/edit-widgets/style-rtl.css 4.1 kB
build/edit-widgets/style.css 4.1 kB
build/editor/index.min.js 37.5 kB
build/editor/style-rtl.css 3.76 kB
build/editor/style.css 3.75 kB
build/element/index.min.js 3.17 kB
build/escape-html/index.min.js 517 B
build/format-library/index.min.js 5.93 kB
build/format-library/style-rtl.css 571 B
build/format-library/style.css 571 B
build/hooks/index.min.js 1.55 kB
build/html-entities/index.min.js 424 B
build/i18n/index.min.js 3.6 kB
build/is-shallow-equal/index.min.js 501 B
build/keyboard-shortcuts/index.min.js 1.72 kB
build/keycodes/index.min.js 1.3 kB
build/list-reusable-blocks/index.min.js 1.85 kB
build/list-reusable-blocks/style-rtl.css 838 B
build/list-reusable-blocks/style.css 838 B
build/media-utils/index.min.js 2.92 kB
build/notices/index.min.js 845 B
build/nux/index.min.js 2.03 kB
build/nux/style-rtl.css 747 B
build/nux/style.css 743 B
build/plugins/index.min.js 1.83 kB
build/primitives/index.min.js 921 B
build/priority-queue/index.min.js 582 B
build/react-i18n/index.min.js 671 B
build/redux-routine/index.min.js 2.63 kB
build/reusable-blocks/index.min.js 2.19 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.6 kB
build/server-side-render/index.min.js 1.5 kB
build/shortcode/index.min.js 1.48 kB
build/token-list/index.min.js 562 B
build/url/index.min.js 1.74 kB
build/viewport/index.min.js 1.02 kB
build/warning/index.min.js 248 B
build/widgets/index.min.js 7.11 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.04 kB

compressed-size-action

Copy link
Contributor

@tellthemachines tellthemachines left a comment

Choose a reason for hiding this comment

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

Thanks for trying this out!

The largest problem with this approach is that horizontal menu + accordion doesn't make much sense, yet it is a valid choice at the moment.

Accordions imply more than just a style change; they bring a whole new behaviour. For instance: the submenus will have to open on click instead of hover. We probably shouldn't even show hover as an option when accordions are enabled. We'll be able to leverage most of the markup we currently use for the open on click option, but we should do some research on whether any further semantics are needed for this pattern, especially from an a11y perspective.

It might make sense to add accordion as another block variation, along with vertical and horizontal. Or else it could be an option, perhaps even something that only appears when open on click is enabled. The design folks should be able to help out with those decisions 😄

The other thing I'm wondering about is what simple navigation links, with no children, will look like with this pattern. They should be visually consistent with the accordion headers, but the semantics will be distinct. Will it be weird to have some top-level items behave as links, and others as accordion headers?

Also, what happens when we add other types of blocks, e.g. site logo, to the navigation? How will they display?

@adamziel
Copy link
Contributor Author

adamziel commented Sep 28, 2021

It might make sense to add accordion as another block variation, along with vertical and horizontal. Or else it could be an option, perhaps even something that only appears when open on click is enabled. The design folks should be able to help out with those decisions 😄

I like making these options mutually exclusive – accordion on hover doesn't make much sense indeed.

Will it be weird to have some top-level items behave as links, and others as accordion headers?

A-ha, there's an issue here:

Assumption: Clicking an accordion header merely opens/closes the accordion. You can't navigate to that page
Problem: Changing between dropdown and accordion implicitly makes some links unreachable.

I wonder what would be a good way to communicate it 🤔 Maybe visually distinguishing the headers from the links? But that could be too vague. CC @jasmussen @javierarce @karmatosed

@jasmussen
Copy link
Contributor

This has come together incredibly fast, and is mighty impressive.

As far as I can tell it boils down to this:

The navigation editor only uses the accordion style, while the page/post editor enables user to choose their favorite flavor

It still leaves me a bit unsure what problem this is trying to solve. While an accordion is a cool feature, it's also a rather complex beast, enough that the ticket for an accordion block has sat there for a while. Even if I can see accordion working as navigation (perhaps weighted towards the vertical variation of the navigation block), I wonder if it's too much complexity to add to an already complex block.

What are some key challenges this needs to address?

@adamziel
Copy link
Contributor Author

Good point @jasmussen! The biggest concern I know of is tight coupling between the navigation block and the navigation editor (#29747). The editor overrides very specific CSS rules to provide the "accordion tree" experience. It works now, but any change in block's CSS could break it.

To solve it, we need to break the coupling. I think there are two ways to do it:

  • Move accordion CSS to the block. To me, it only makes sense if it's actually used and this PR is attempt at just that.
  • Don't rely on block styles in the navigation editor. @talldan proposed styling the editor from scratch, thus removing the CSS coupling. It would still rely on markup, but I think it changes less frequently.

@talldan
Copy link
Contributor

talldan commented Sep 29, 2021

There are original user-facing problems that pre-date the technical problems @adamziel mentioned.

The visual presentation of the navigation block has been built with full-site editing in mind where the editor closely matches the frontend. That's not the case in the navigation editor, the block will almost never match the frontend. There is no advantage to presenting the navigation block with a 'dropdown' style there. Compared to the classic menu editor, it's potentially harder for a user to build a menu with dropdowns. That's why the more structural accordion style was introduced in the editor.

Before this there were some other explorations, like using List View for editing menus in a more structural way alongside the block. Those didn't work out for one reason or another.

In terms of why the idea came up of introducing this accordion style in the block, there has been an expression of interest in different styles of navigation menus, including an accordion, so it seems like a good opportunity to converge. It may not be the right time or solution, it's open to debate.

@talldan
Copy link
Contributor

talldan commented Sep 30, 2021

I have some additional thoughts. 😄

I've realised there's a lot of relevance between this and the comment here (which also closely relates to this issue - #34612.)

That relevance is that if the future navigation block saves its inner blocks to a custom post type (or template part) to become reusable, then in an FSE theme there's very likely to be a use case for editing a navigation block's content alone (isolated editing). The block data that's being edited may not be assigned to template at all, in which case the theme will not be able to provide complete styling for it (we don't know if it should look like a header nav block or a footer nav block or a sidebar nav block).

The thing that has occurred to me is that this is very a similar use case to the navigation editor, so the block should probably cater for it in the future.

I'm thinking the navigation block could offer something more akin to a plain structural view when it's used in a context in which the theme cannot provide an opinionated style. This would be when the block is in the navigation editor in the 'classic mode' where the menu is still rendered using a walker. It's not possible to visually match the front-end style. Or as outlined above there's an FSE use case when a navigation block's data is being edited in an isolated way.

Furthermore, it's probably worth thinking about how the block could have sensible default styling based on the template it will be used. Using dropdown menus in a header and maybe something more akin to a list in a footer.

@adamziel adamziel changed the title Accordion as navigation block style Accordion as navigation block attribute Sep 30, 2021
@adamziel
Copy link
Contributor Author

adamziel commented Sep 30, 2021

Here's an attempt number 2: We have a block attribute called expandEffect and it takes one of two values: "dropdown" or "accordion". Accordion is only available if the navigation uses vertical orientation. Here's now the UI looks like:

Zrzut ekranu 2021-09-30 o 15 56 57

Zrzut ekranu 2021-09-30 o 15 57 09

I think it plays well with the direction of custom post types / template parts – it's just an attribute on the top-level navigation block, and different blocks could render the same menus using different "display modes".

What do you think @talldan?

(There are some conflicts, but I'll refrain from investing time in solving them until we converge on direction)

@talldan
Copy link
Contributor

talldan commented Oct 1, 2021

I'd defer to @jasmussen and @tellthemachines for the best feedback here as I know they've worked lots on these options and have some plans for changing how they appear.

The challenge is probably having smart defaults, so when selecting accordion, it should probably enable (and prevent modification of) 'click to open submenus' and also switch to vertical. It does feel more like a block variation in that respect, but to do that we'd need to tackle removing the horizontal/vertical variations as per #34872.

@tellthemachines
Copy link
Contributor

My main concern here is that creating an accordion version (variation, or whatever it might be) of Navigation will require us to solve a bunch of complex problems, some of which I raised in my comment above. Plus we have to solve those problems in a way that's compatible with its use in the Nav editor.

For instance:

Assumption: Clicking an accordion header merely opens/closes the accordion. You can't navigate to that page
Problem: Changing between dropdown and accordion implicitly makes some links unreachable.

If top-level items in an accordion become static text, can we still treat them as links in the Nav editor? Because in an appearance-agnostic context, they should still be links.

But perhaps these are problems that we should be attempting to solve anyway; the accordion (often sliding in from the side) is a common navigation pattern across the internet and it would be great to offer it as a possibility.

If so, it's different enough from the existing pattern that it would make sense as a block variation, especially if we're removing vertical/horizontal in #34872. Then we could set it to open on click and disable any other options that don't apply.

We should also consider adjusting the responsive menu to match when accordion is selected, because it's a pattern that works well on small viewports.

I don't think that the solution of decoupling the Nav editor from block styles is necessarily a bad one though. It'll certainly be a lot easier than implementing accordion for the block 😅 and it'll free us from having to check the editor each time we make adjustments to block styles.

@jasmussen
Copy link
Contributor

I can add little value to what @tellthemachines already shared, only agree. The accordion behavior is definitely valid and valuable, but due to the likely complexity it will bring it might be useful to keep it separate from the already complex Navigation block (#21584) and then look at converging in the future if that becomes useful.

@draganescu
Copy link
Contributor

The thing that has occurred to me is that this is very a similar use case to the navigation editor, so the block should probably cater for it in the future.

@talldan I think this is a very, very good insight 👏🏻 That accordion vertical thing should be a good data-only-view in the block itself. This block easily becomes a world of its own 😂

@adamziel adamziel force-pushed the add/accordion-and-dropdown-as-style-variations branch from 9c144ba to 5ece076 Compare October 8, 2021 13:59
@adamziel adamziel changed the title Accordion as navigation block attribute Add tree view to the navigation block Oct 8, 2021
@adamziel
Copy link
Contributor Author

adamziel commented Oct 8, 2021

I pivoted this PR towards a editor-only "tree view" feature for the navigation block:

Kapture.2021-10-08.at.16.12.19.mp4

Now we don't need to solve any frontend issues with accordion on the first go. Oh, ant the icon is terrible – any suggestions which one would fit better? cc @tellthemachines @jasmussen @draganescu @talldan


// Styles for dropdown style menu.
.wp-block-navigation:where(:not(.is-tree-view)) .has-child {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like how an editor-only classname creeps into style.css, but I don't think there's an easy way around this – style.scss is loaded in the editor so it needs to acknowledge editor matters.

@tellthemachines
Copy link
Contributor

I don't think we should go in this direction, because this doesn't add value to the Navigation block itself. We already have list view, which works the same for all blocks at all nesting levels.

The problem we're trying to solve, as stated in #29747, is the brittleness of Navigation block styles inherited by the editor.

We know that we want to optimise editor styles for ease of editing, not WYSIWYG; that's how we arrived at the current editor layout. So it makes sense for the editor to have its own styles, independent from Navigation block styles, which are geared towards WYSIWYG. Also, the exploration in #35418 is a big step in the direction of decoupling navigation content from presentation, and in that case editor specific styles will be necessary.

@talldan
Copy link
Contributor

talldan commented Oct 11, 2021

We know that we want to optimise editor styles for ease of editing, not WYSIWYG; that's how we arrived at the current editor layout. So it makes sense for the editor to have its own styles, independent from Navigation block styles, which are geared towards WYSIWYG. Also, the exploration in #35418 is a big step in the direction of decoupling navigation content from presentation, and in that case editor specific styles will be necessary.

I think it's worth questioning this. If the block moves towards storing content in something like a template part or CPT, then full-site editing will also have the same problem. There will very likely be a way to edit that template part/CPT in isolation. When doing so what should the block look like?

@draganescu
Copy link
Contributor

When doing so what should the block look like?

In a block context we can/should rely on the list view IMO.

@talldan
Copy link
Contributor

talldan commented Oct 12, 2021

In a block context we can/should rely on the list view IMO.

Would you be able clarify your thoughts here. What's a 'block context'? I find this term a bit confusing because there's a feature called block context.

Also, it should rely on 'list view' as in the List View feature? Should rely on it to do what? That seems like a non-sequitur because it's unrelated to the text you quoted which was asking what the block should look like.

@getdave
Copy link
Contributor

getdave commented Oct 13, 2021

The problem we're trying to solve, as stated in #29747, is the brittleness of Navigation block styles inherited by the editor.

What if the Nav block isn't included in the Nav Editor at all? Isn't this what might happen if we start treating Nav block as a presentational container and saving the inner blocks to an entity?

In this world, the Nav Editor becomes another Isolated Template Part editor concerned with managing the inner nav blocks only (no core/navigation block). Therefore no styles are inherited (in theory) from the Navigation block.

We would, of course, have to duplicate some CSS from the Nav block to provide a vertical layout for the Nav Editor, but that would be much easier than overriding the CSS coming down the pipe from the Navigation block.

Again, imagine the inner blocks are all either raw (no configuration just representative of data) or they are configured via attributes defined on the parent Navigation block. Therefore if no parent Nav block exists then none of the configuration applies to the child nav blocks and thus we get a nice "raw" representation in the Nav Editor onto which we can sprinkle some simple styling.

What do folks think? Am I on the wrong page here or does conceptualising the Nav block/editor like this work?

@talldan
Copy link
Contributor

talldan commented Oct 14, 2021

What do folks think? Am I on the wrong page here or does conceptualising the Nav block/editor like this work?

I think this has been discussed a bit across issues. (#30007 (comment), #34496)

There are some caveats. Some of the behaviors defined by the block will no longer work. Things like the new direct insert and default block behavior need to be replicated. Some of the inner blocks also have a parent, which will prevent them from being inserted unless there's a way to circumvent that. Plus, the opposite is true, you can insert any other block (paragraph etc) without a locked nav block wrapper. You can see it in action on #35418.

So there are trade-offs both ways really.

I still think it'd be more elegant if the navigation block were more contextually aware ... it needs to know "am I being rendered within a parent block list (am I being saved to something), or am I the root (am I only saving my data)", and then its behavior changes dependent on that. If it's being rendered within a template part, sidebar, post or page, it can have styling options as there's somewhere to save that (to the parent block list). If the navigation block is the root and there's no parent, there's basically no way to save those styles, so it shouldn't present styling options. There's also no way to know how the block should look visually and so it should maybe present itself more as a hierarchical structure.

@draganescu
Copy link
Contributor

In a block context we can/should rely on the list view IMO.

@talldan what I mean is that when we are in a block editor that edits content which will be rendered as blocks, we already have the List View feature so we don't need to change the way the block looks to make navigating its contents easier.

There is no point in my head to change how the block edit looks and works depending on wether it is edited in isolation or not, except when we don't have a block rendering target (like we do when editing classic menus with a block editor) and the visual correspondence does not exist anymore.

I mean, isn't the List View in the sidebar enough for a schematic data representation of the navigation block without visual enhancements? Why would we need another feature, specific to one block, for this?

@talldan
Copy link
Contributor

talldan commented Oct 19, 2021

except when we don't have a block rendering target (like we do when editing classic menus with a block editor) and the visual correspondence does not exist anymore.

@draganescu I think this is the important bit, what should the block look like in this case?

And there's also a situation where a single 'menu' can be rendered in multiple places, so how should it look in that situation?

@tellthemachines
Copy link
Contributor

I think this is the important bit, what should the block look like in this case?

I think we're all agreed that an accordion-like view such as we currently have in the Navigation editor is the best for this situation 😅 but we haven't reached a decision on where the styles for such a view should live.

I'm not convinced that we should bundle these styles in with the Navigation block, because they are unrelated to the block's presentation; they style an editor view of the block content, not the block itself.

Instead, I think we should consider having these styles in the navigation editor package.

And there's also a situation where a single 'menu' can be rendered in multiple places, so how should it look in that situation?

In light of #35746 and #35418, I assume that this would be the view of the navigation post type/template part that we're able to access from the "Appearance" menu in wp-admin?

Can we leverage the navigation editor for this view too? Given we'd only be viewing the contents of the menu, I think that would make sense. And in that case, having the styles in the editor package would be the obvious choice.

@talldan
Copy link
Contributor

talldan commented Oct 21, 2021

I think we're all agreed that an accordion-like view such as we currently have in the Navigation editor is the best for this situation 😅 but we haven't reached a decision on where the styles for such a view should live.

I'm not convinced that we should bundle these styles in with the Navigation block, because they are unrelated to the block's presentation; they style an editor view of the block content, not the block itself.

There's an editor.scss file specifically for this.

Instead, I think we should consider having these styles in the navigation editor package.

It's how it already works and it's considerably problematic for a number of reasons. Contributors don't expect to find block styles outside of the block-library package, so regularly don't update those styles. Better to have them with the block where folks expect them to be.

Having them elsewhere completely breaks the BEM concept.

@tellthemachines
Copy link
Contributor

It's how it already works and it's considerably problematic for a number of reasons. Contributors don't expect to find block styles outside of the block-library package, so regularly don't update those styles.

The problems we've been having with style updates to the Nav block not being tested in the editor are mostly due to the editor using some of the block styling though, aren't they? If the editor view were completely independent from block styles that wouldn't be an issue.

We also need to think about how this will work with Navigation as a custom post type. In that case, the editor likely won't be rendering the nav wrapper at all, so importing its styles might not make sense.

Having them elsewhere completely breaks the BEM concept.

I thought BEM was more about naming conventions than where the styles are located. In any case, we're already not really BEM-compliant 😅

@talldan
Copy link
Contributor

talldan commented Oct 21, 2021

The Navigation Editor isn't an answer because that won't be shipped in 5.9. We need to be realistic, it won't be possible to pivot on the Navigation Editor because that's months of work. Lets focus on FSE here.

We also need to think about how this will work with Navigation as a custom post type. In that case, the editor likely won't be rendering the nav wrapper at all, so importing its styles might not make sense.

This is actually the only thing we need to think about right now. And it's what I've been taking about the whole time (#35149 (comment)).

We can see in #35746 that the block styles are still wrong when editing without a wrapping nav block, and we've also established that it also wouldn't be quite right when there is a wrapping nav block and editing a CPT in isolation.

I realise #35746 is still a bit up in the air, so I think we need to take a bit of a step back from just these styling challenges and think more solidly about how editing that nav block CPT in isolation will work. Styling is just one of the challenges.

@adamziel
Copy link
Contributor Author

adamziel commented Oct 25, 2021

What I'm hearing is that there is nothing directly actionable in this PR for now. It seems to be interdependent with the isolated editor work (cc @kevin940726). Let's put it on hold for now and keep coming back to discuss new ideas as they emerge from all the FSE explorations.

@adamziel adamziel closed this Jul 25, 2022
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants