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

Fix Navigation block fallbacks and entity saving #42799

Closed
5 tasks done
scruffian opened this issue Jul 29, 2022 · 2 comments
Closed
5 tasks done

Fix Navigation block fallbacks and entity saving #42799

scruffian opened this issue Jul 29, 2022 · 2 comments
Labels
[Block] Navigation Affects the Navigation Block

Comments

@scruffian
Copy link
Contributor

scruffian commented Jul 29, 2022

This is an overview Issue to track the requirements to fix and improve the fallback and entity saving states for the Navigation block.

Where possible, the aims are:

  • always to have 1:1 parity between what is displayed in the Editor and what is shown on the front of site
  • to have the block "just work" and automatically choose and appropriate fallback in lieu of a user defined menu.
  • to simplify and normalize the code ready for working on Preserve the navigation on theme switch #38291 (comment)

Tasks

Summary of States for Block

Below is a summary of the different states the navigation block can be in, and how we should handle editing and saving it in each case. This is quite a big departure from how things work today technically.

Empty Navigation Block

Assuming an empty navigation block on the page….

  • When the user has no navigation menus (classic or CPT), show a page list block on both the frontend and the editor
  • When the user has only one navigation menu (classic or new) we show this menu on both the frontend and the editor. This is not considered a “dirty” state, since the frontend and the backend are the same.
  • When the user has multiple navigation menus we try to find the one with a slug that most closely matches the position of the block in the template, and display that in the frontend and the editor. If a user only has classic menus then the menu saved to the “primary” location should be used. Navigation menus CPTs will take precedence over classic menus.
  • When the user modifies the block, in any of the above scenarios, the edits are NOT saved to the database, instead the block becomes a dirty entity. No changes are made to the front end of the site.

Existing Navigation block

If the user has a navigation block that already has a connection to a navigation menu CPT

  • We show the same thing in the frontend and in the editor
  • If they make an edit, no change happens in the database (effectively the change is stored in memory in the client), and the navigation block becomes a dirty entity

Create new navigation

The user can select “create new menu” from the block toolbar. The should also be able to select this “Start empty” from the inspector when the block is in a fallback state (or maybe at any time).

  • A new empty navigation menu is displayed in the editor, but no change is made to the frontend
  • Nothing is yet saved in the database
  • Changes made to the block are stored only in memory in the editor

Saving navigation

When the user hits save they get the option to save their navigation menu, like the ones for site title and templates, because its a dirty entity (see image below). If they save the block to a navigation menu (the default) then the frontend updates to match the editor.

Screenshot 2022-07-28 at 12 45 11

@scruffian scruffian added the [Block] Navigation Affects the Navigation Block label Jul 29, 2022
@getdave
Copy link
Contributor

getdave commented Jul 29, 2022

Related to #38291 (comment)

@draganescu draganescu self-assigned this Aug 3, 2022
@getdave getdave changed the title Proposal: Navigation block fallbacks and entity saving Fix Navigation block fallbacks and entity saving Aug 3, 2022
@getdave getdave added this to 📥 To do in Navigation block via automation Aug 3, 2022
@draganescu draganescu removed their assignment Aug 15, 2022
@scruffian
Copy link
Contributor Author

This is complete.

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
Development

No branches or pull requests

3 participants