Problem/Motivation

Currently, this module provides a "Save and Edit Layout" button on an entity's layout page, as well as a bundle's default layout form. This button would also be useful on an entity's edit page. For example, when a content editor first creates a node, they would give the node a title and click 'Save'. It would be useful to be able to navigate directly to the node's layout page immediately after saving the node.

Proposed resolution

Add "Save and Edit Layout" button to entity edit pages.

Remaining tasks

  • Open MR
  • Review

User interface changes

Adds "Save and Edit Layout" button on entity edit pages.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Chris Burge created an issue. See original summary.

chris burge’s picture

Issue summary: View changes

MR is open and ready for review.

chris burge’s picture

Assigned: chris burge » Unassigned
dave reid’s picture

Status: Active » Needs review

I think the appearance of two primary buttons looks a little odd on both the content edit form and the layout builder form. We should pick one of the buttons to be the primary. I would think when creating new content, the primary action I would prefer to see on the node form is "Save and Edit Layout" and the regular "Save" button to be a secondary button, but when editing existing node forms, I would expect the normal "Save" to be the primary button only. I'm not sure which one should be the primary button on the layout builder form.

chris burge’s picture

@Dave Reid - That's a good catch. My vote would be to make the "Save and edit layout" button secondary in both instances. I think making the button's appearance/order dependent upon whether the entity is new or not would feel more inconsistent than helpful for editors.

chris burge’s picture

Update: We're going to get feedback from a UX designer next week.

chris burge’s picture

Screenshots below. (I used Olivero as the front-end theme since Bartik doesn't visually differentiate between primary and secondary buttons.)

Edit page (without module enabled):
Edit page without module enabled

Edit page (current MR):
Edit page current merge request

Edit page (current MR + secondary button):
Edit page current merge request as secondary button

Edit page (current MR + secondary button + order change):
Edit page current merge request as secondary button and order change

Layout page (without module enabled):
Layout page without module enabled

Layout page (current MR):
Layout page current merge request

Layout page (current MR + secondary button):
Layout page current merge request as secondary button

chris burge’s picture

chris burge’s picture

I think that making the "Save and edit layout" button secondary is the best solution given existing Drupal design patterns.

galactus86’s picture

How can I help test this out? I'm not as familiar with the MR thing.

neslee canil pinto’s picture

@galactus86 you need to checkout to branch 3246699-add-save-and and then you will get these changes to test.

jonzhang’s picture

Status: Needs review » Reviewed & tested by the community

I've tested the save and edit layout button, it works as intended and show up correctly in order and in style. Nicely done!

jayhuskins’s picture

The button does not properly redirect because the submit handler is checking for the exact ID of the triggering element. This is prone to failure because when forms rebuild, Drupal automatically appends digits to element ID's to ensure they stay unique, so the ID becomes something like edit-layout-builder-save-and-edit-layout--1.

I would suggest checking against a different property such as the data-drupal-selector attribute.

jayhuskins’s picture

StatusFileSize
new799 bytes

Here is an interdiff patch from the current MR to switch the validation from checking the ID to the data-drupal-selector.

jayhuskins’s picture

Personally, the entity creation form is where I most want a submit button to go straight to layout builder. The trick is that those forms do not have an entity ID until they are submitted. This means we can't check if the layout builder route exists or if the user has permission to access that route until the submit handler. Note we would need to set our submit handler as the last in the stack to access the entity ID.

We should be able to check if layout builder is enabled on the bundle with out an entity ID, but even so we may end up displaying a button to a user without access to the layout builder page.

Should we check the current user against known permissions rather than the exact route?

jayhuskins’s picture

Status: Reviewed & tested by the community » Needs review
froboy’s picture

Status: Needs review » Reviewed & tested by the community

I've added MR4 on top of v 1.0.2 of the module with Drupal 10.0.9. It applies successfully and works as intended. I've tested:

- The "Save and edit layout" button appears on a node creation page for content types where Layout Builder is enabled
- The button does not appear on node creation pages where LB is not enabled
- The button appears on a node edit page for content types where Layout Builder is enabled
- The button does not appear on node edit pages where LB is not enabled

I've inspected the code and it looks good. Requesting one more person to code review as well.

froboy’s picture

StatusFileSize
new12.29 KB

Uploading point-in-time patch for composer.

podarok’s picture

Priority: Normal » Major
podarok’s picture

Version: 1.0.x-dev » 1.0.3
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.