WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.36k stars 4.14k forks source link

Admin bar: Edit site link should open the current template #37850

Closed carolinan closed 1 year ago

carolinan commented 2 years ago

Description

Often when I use the "Edit site" link in the WordPress admin bar, it is because I want to edit the current template. This can be a post/page or an archive (they should all work the same).

Instead, the link opens the index/home/front-page, and I have to find a way to navigate to the template I wanted to edit.

Step-by-step reproduction instructions

With a full site editing theme active:

  1. Login.
  2. Navigate to an archive page.
  3. Click on the edit site link in the WordPress admin bar.
  4. See that the home page opens, not the page you were viewing.

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

alexstine commented 2 years ago

Makes sense to me. Less clicks for sure. Would make it work the same as Edit Post/Page/other post type. I would not be happy if I clicked Edit Post and got taken to the list of posts vs. the post I wanted to edit.

carolinan commented 2 years ago

Alternatively, let this menu have two links, "Edit site" and "Edit template" which would lead to the current template, either in the site editor (for site templates) or the template editor (for single post/pages).

beckej13820 commented 2 years ago

Just dropping by to add a +1. I have found myself doing a lot of clicking around going into and out of Full Site Editing. The two biggest issues are the preview button not working in FSE, and not being able to get directly back to the template I am looking at from the front end.

annezazu commented 2 years ago

This was noted in the fifteenth call for testing for the FSE Outreach Program, which has a focus on creating and editing the categories template:

After visiting the newly created categories template, I went to the Site Editor again to fix a mistake I made earlier. However, when you click on “Edit site” in the admin bar, instead of loading the template you were just on, the home page template gets loaded. It would be better if the template you’re currently on, so in this case when I hit the “Edit site” button while I’m on a category page, I’d like to be directly taken to the Category template.

& again in a separate comment:

It is a bit odd to me that the toolbar on the frontend of the site has an “edit page” option sometimes, but not for all pages. I wonder if still having an edit page, there could be an “edit template” button or something if it’s a template and not a page?

& even more in an additional comment:

It would also be nice if the Edit Site button, would bring you to the template you were currently viewing. For now it seems to always just bring you to the homepage by default, then you have to go to templates and load the template you want to edit. Would be a lot easier to have the edit site be context aware.

jameskoster commented 2 years ago

I think a single 'Edit template' link could make sense as an accompaniment to 'Edit post'. We might even combine them into a single dropdown.

One other thing to consider is when to pass context to base templates. For example if I'm viewing my 'Hello World!' post and it uses the single template, what do I see when I click 'Edit template'? If we populate the template with the post content, folks might be misled into thinking the template only serves that one post. If we don't, would the transition be too abrupt, or confusing?

bacoords commented 2 years ago

Because this is a UX pattern that we see pretty consistently in other page builders, I built a simple plugin (unaware of this open issue) to tackle this for myself. There's some holes in how we can determine the templates, so I think the final approach would require some better infrastructure to determine the active templates/template parts ( #32309 being a good example).

I'm just including a link to my repo as a functional design proof of concept. I basically added some dropdown nodes under the "Edit site" link with more specific links to the templates that are visible. So a user could still select 'Edit Site' or they could navigate to a specific template/part by selecting one of the dropdown links.

https://github.com/bacoords/site-editor-links

clubkert commented 2 years ago

I think a single 'Edit template' link could make sense as an accompaniment to 'Edit post'. We might even combine them into a single dropdown.

  • Edit
    • Post
    • Template

This is an interesting idea when looking to edit a template for a post.

There are also times when there would only be an option to edit the template (i.e. there is not post), like the 404 page. In the below example, if I click "edit site" it just takes me to the main site editor (not the 404 template).

Screen Shot 2022-08-26 at 9 00 23 AM

carolinan commented 1 year ago

I made an attempt at this:

porg commented 1 year ago

@annezazu and @getdave — Continuing here as you recommended.

@carolinan — The essence of my issue #49438 was a duplicate of this your very issue here.

@all

paaljoachim commented 1 year ago

It is really good to see this issue being worked on! I have met the same thing as well. Clicking Edit Site only goes to the Front Page Template. I expected it to open the template related to the page that I am on.

getdave commented 1 year ago

It's my understanding that this would eventually require a Core patch for the Edit link in the admin bar. It would also require that all the routes in the Site Editor are stable as public APIs (I'm not sure whether this is the case yet).

I could not personally commit to working on this feature at this point in the release cycle. However, it is open for contributions should anyone like to take a look.

The work @bacoords did in his Plugin looks like a good starting point. It could land initially in Gutenberg via the hooks API and thus won't need a Core patch.

priethor commented 1 year ago

Opening the current template is the only logical outcome and what most users might expect. We should address this malfunction sooner rather than later.

skorasaurus commented 1 year ago

If this is resolved; there probably should be a hook exposed so that developers can obtain what template(s) are currently being rendered; solving https://github.com/WordPress/gutenberg/issues/32309

porg commented 1 year ago

@carolinan — Please copy my graphics from #49438 to your issue description on top.

Mamaduka commented 1 year ago

I just created a core PR for this enhancement.

Links

@porg, do you mind attaching your visual aid graphs to the core ticket - https://core.trac.wordpress.org/ticket/58746?

porg commented 1 year ago

@Mamaduka

@carolinan and everyone

getsource commented 1 year ago

Thanks so much everyone!

I'm going to close this, as it should be fixed in this commit: https://core.trac.wordpress.org/changeset/56209

If you notice this is not the case, please feel free to reopen!

autumnfjeld commented 1 year ago

For clarity, just confirming this the wordpress admin bar, yes?

image
annezazu commented 1 year ago

Yes. What you are showing appears to be something related to WordPress.com and not WordPress Core functionality.