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

"Manage Locations" doesn't work on the Navigation screen #33815

Closed
Mamaduka opened this issue Aug 2, 2021 · 11 comments · Fixed by #34714
Closed

"Manage Locations" doesn't work on the Navigation screen #33815

Mamaduka opened this issue Aug 2, 2021 · 11 comments · Fixed by #34714
Assignees
Labels
REST API Interaction Related to REST API [Type] Bug An existing feature does not function as intended

Comments

@Mamaduka
Copy link
Member

Mamaduka commented Aug 2, 2021

Description

Currently, it's not possible to assign menu locations to a different menu using the "Manage Locations" modal.

Step-by-step reproduction instructions

Tested using TT1 theme.

  1. Go to the experimental Navigation screen.
  2. Create two menus.
  3. Assign both locations to the first menu.
  4. Open the "Manage Locations" modal.
  5. Assing both locations to the second menu.
  6. Save menu and refresh page.
  7. Locations aren't reassigned.

Expected Behavior

The editor shouldn't assign menu locations to the second menu.

Current Behavior

The editor doesn't assign menu locations to the second menu.

Screenshots or screen recording (optional)

CleanShot.2021-08-02.at.16.30.27.mp4
@Mamaduka Mamaduka added [Feature] Navigation Screen [Type] Bug An existing feature does not function as intended labels Aug 2, 2021
@Mamaduka
Copy link
Member Author

Mamaduka commented Aug 2, 2021

I'm not sure if this action was ever possible. The assignMenuToLocation callback only changes data for the current menu.

const assignMenuToLocation = useCallback(
async ( locationName, newMenuId ) => {
const oldMenuId = menuLocationsByName[ locationName ].menu;
const newMenuLocationsByName = merge( menuLocationsByName, {
[ locationName ]: { menu: newMenuId },
} );
setMenuLocationsByName( newMenuLocationsByName );
const activeMenuId = newMenuId || oldMenuId;
editMenuEntityRecord( ...menuEntityData, {
locations: locationsForMenuId(
newMenuLocationsByName,
activeMenuId
),
} );
},
[ menuLocationsByName ]

I think these assignments should be handled by __experimental/menu-locations, which currently is read-only.

/cc @getdave, @talldan, @spacedmonkey.

@draganescu
Copy link
Contributor

I tested this and indeed the modal does not set the location, only the UI is updated.

@Mamaduka
Copy link
Member Author

Thanks for testing, @draganescu.

Do you think we should update the menu-locations endpoint to handle updating multiple locations?

@talldan talldan added the REST API Interaction Related to REST API label Aug 10, 2021
@talldan
Copy link
Contributor

talldan commented Aug 10, 2021

@Mamaduka It may also be possible to use the batch API for this kind of thing.

Would be good to get input from the REST API team. I see Jonny (spacedmonkey) has already been pinged. @TimothyBJacobs do you have any thoughts?

@getdave getdave changed the title Navigation Screen: "Manage Locations" doesn't work "Manage Locations" doesn't work on the Navigation screen Aug 24, 2021
@TimothyBJacobs
Copy link
Member

A menu's location is managed via the menus endpoint. Is there a reason we can't use that endpoint here?

protected function handle_locations( $menu_id, $request ) {

@spacedmonkey
Copy link
Member

The menus endpoint should be used here. In my testing a request like this worked.

await wp.apiFetch({path: "__experimental/menus/43", data: { locations: ['primary'] }, method: 'POST'})

Menu locations are a static endpoint, like taxonomies or post types. Menu locations assignment happens at the menu level.

@talldan
Copy link
Contributor

talldan commented Aug 31, 2021

I think the issue is that the UI allows for assigning multiple menus to locations at once.

So I guess in this case it'd be best to batch multiple requests to the menus endpoint @TimothyBJacobs @spacedmonkey?

The modal should probably also have its own save button:
Screenshot 2021-08-31 at 11 00 29 am

Because here we're managing multiple menus, but the save button at the top of the editor only saves the current menu (which is the root problem here).

@anton-vlasenko
Copy link
Contributor

anton-vlasenko commented Sep 2, 2021

Because here we're managing multiple menus, but the save button at the top of the editor only saves the current menu (which is the root problem here).

Yes, I agree. That's the root problem.
What if we just fix how it saves menu locations so that we don't have to add another "Save" button to the modal?
Theoretically, if we fix this we won't have to change anything else.

@talldan
Copy link
Contributor

talldan commented Sep 3, 2021

I feel like a dedicated Save button could be a better experience, a bit like the current menu screen. But I'd defer to @javierarce's opinion.

I noticed this morning there was some design feedback on the tracking issue mentioning the location of Manage Locations - #29102 (comment), so maybe this could be revisited anyway.

edit: There's an issue to tidy up some of the rough edges of the editor's main save button - #31813.

@TimothyBJacobs
Copy link
Member

So I guess in this case it'd be best to batch multiple requests to the menus endpoint @TimothyBJacobs @spacedmonkey?

Yep!

@javierarce
Copy link
Contributor

I feel like a dedicated Save button could be a better experience, a bit like the current menu screen. But I'd defer to @javierarce's opinion.

The sidebar (and its save button) should only affect the current menu, so I agree with @talldan: we need to have a save button inside the modal and we should also show a snackbar message to indicate that the locations were updated.

Otherwise, it gets super confusing if, for example, I reassign locations and then click the edit button next to an item. In that case, I'm not sure if I'll need to click save in the new menu or what happened to the other locations. Did I lose those changes? It's difficult to tell.

In any case, I think we'll need to revisit the interface of this modal and the corresponding section of the sidebar to make it less confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REST API Interaction Related to REST API [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants