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

Multiple navigation menus are being created #38157

Closed
lumpysimon opened this issue Jan 22, 2022 · 7 comments
Closed

Multiple navigation menus are being created #38157

lumpysimon opened this issue Jan 22, 2022 · 7 comments
Labels
[Block] Navigation Affects the Navigation Block [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended

Comments

@lumpysimon
Copy link

Description

I'm running 5.9-RC3 with Twenty Twenty Two theme. Gutenberg plugin is not installed.

Multiple navigation menus are being created even though I have not added any, when I go between the new site editor and the manage menus screen.

Step-by-step reproduction instructions

  • Click 'Edit site' in the admin toolbar.
  • Click on the header navigation menu block.
  • Click 'Select menu'.
  • Click 'Manage menus'.
  • There is one menu listed, called 'Header navigation'.
  • Do nothing on this screen, then navigate to 'Appearance' > 'Editor'.
  • Click on the header navigation menu block.
  • Click 'Select menu'.
  • There are now two navigation menus showing ('Header navigation' and 'Header navigation 2').
  • Repeat the above steps, each time a new navigation menu is created.

At no point during this process have I clicked 'Add new' on the menus page, clicked any 'Publish' buttons, etc.

Screenshots, screen recording, code snippet

Screenshot 2022-01-22 at 13 15 37

Environment info

WordPress 5.9-RC3
Twenty Twenty Two theme
Gutenberg not installed
MacOS 12.1
PHP 7.4 (site is running locally using Valet)

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@Mamaduka Mamaduka added the [Block] Navigation Affects the Navigation Block label Jan 22, 2022
@Mamaduka Mamaduka added the Needs Testing Needs further testing to be confirmed. label Jan 22, 2022
@Mamaduka
Copy link
Member

/cc @talldan, @getdave

@talldan
Copy link
Contributor

talldan commented Jan 24, 2022

Thanks for reporting this. To explain what's happening:

  1. The theme provides some initial menu content
  2. When selecting the navigation block with this content, a Navigation Menu is created
  3. At the point, the changes to the template and the new menu need to be saved to avoid duplicates

The duplicates should only happen if when exiting the site editor the warning about unsaved changes is ignored.

I agree it is confusing, and something that should be improved.

I did mention the problem with duplicate menus in my feedback on the PR - #36024 (comment) - but this is the direction others wanted to take.

Perhaps the best option is if the block could check whether another menu with the same content already exists before creating a new one. Maybe menus created this way could have some kind of flag (e.g. wasInitialThemeContent: true), and then before creating a new menu, the block can check any menus with this type to see if they have the same original content.

@getdave
Copy link
Contributor

getdave commented Jan 24, 2022

When selecting the navigation block with this content, a Navigation Menu is created

Why do we have to save immediately if there have been no changes? Why is there even a "dirty" state?

Is there a way we can adjust the flow so that we only save a new menu if there have been changes?

@getdave getdave added [Type] Bug An existing feature does not function as intended and removed Needs Testing Needs further testing to be confirmed. labels Jan 24, 2022
@talldan
Copy link
Contributor

talldan commented Jan 24, 2022

Is there a way we can adjust the flow so that we only save a new menu if there have been changes?

It would be good to try. Saving is asynchronous, so it would have to be pretty seamless and not interupt the user's editing.

It still only mitigates the issue though, the user can choose not to save changes in the site editor (which avoids assigning the ref in the nav block), and they would still get another menu when they next go to edit (because there's no ref assigned). Granted it does reduce the problem as users are less likely to edit compared to selecting the block.

@talldan
Copy link
Contributor

talldan commented Mar 16, 2022

I've outlined a couple of options for solving or improving this in #39489.

@mtias mtias added the [Priority] High Used to indicate top priority items that need quick attention label Mar 29, 2022
@getdave
Copy link
Contributor

getdave commented Apr 5, 2022

IN #39883 weve now updated things so that Nav blocks that:

  • are provided by a Theme template
  • are inserted via a Pattern
  • are created manually via Code View

...will only be converted to a Navigation Menu entity if the user modifies the original blocks.

So if your Theme includes a Nav block it won't get saved as a Navigation Menu until you click on it and make some changes to the menu items. At that point it saves.

This should avoid so many menus being created because no longer does focusing the Nav block cause a Nav Menu to be created.

@jordesign
Copy link
Contributor

With #39883 closed - and no further reports of this kind - I'm going to close this issue as well.

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 [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

6 participants