Cancel button on the discard changes in the layout builder confirmation step should take you back to the layout builder

Created on 12 March 2024, 3 months ago
Updated 20 April 2024, 2 months ago

Problem/Motivation

Let's say you've reordered the blocks for the article content type in Layout Builder from the default:

  • Image
  • Body
  • Tags
  • Links
  • Comments

to

  • Tags
  • Body
  • Image
  • Links
  • Comments

You click now the Discard changes button. Let's say you have a small working memory, you then get distracted and pull away from the computer and you cant remember what the changes were you've made when you return. Now you want to discard those changes. On the confirmation page for discarding the changes you have two buttons as options: Confirm and Cancel.

Clicking the confirm button brings you back to the Manage display page and an info admin message informs you that the changes to the layout have been discarded. You are back to the default order of blocks.

If you click the Cancel button instead the outcome is different and sort of unexpected. Technically to cancel something means to stop the started task and go back to the starting point/revert a step. But instead you are also getting forwarded back to the Manage display page, but in contrast clicking the confirm button, you don't have any info admin message but the changes to the layout get saved anyway.

Steps to reproduce

  1. Go to /admin/structure/types/manage/article/display/default
  2. Activate Layout Builder
  3. Change the order of the default blocks to Tags, Body, Image, Links, Comments
  4. Click the Discard changes button
  5. Click confirm
  6. Reapply the changes to the block order for the layout
  7. Click the Discard changes button again
  8. Click the Cancel button

Proposed resolution

i would lean towards the following when the Cancel button is pressed/clicked. Instead of saving the layout and forwarding back to the Manage display page redirect back to the page of the layout so the user is able to continue with the already made changes.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Fixed

Version

11.0 ๐Ÿ”ฅ

Component
Layout builderย  โ†’

Last updated about 8 hours ago

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany rkoller Nรผrnberg, Germany

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @rkoller
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    aaron.ferris โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    Currently both actions (Confirm/cancel) result in $this->sectionStorage->getRedirectUrl()

    Pushed a commit to the fork, which:

    1. On discard confirm - redirects to node/x (with changes discarded) - same as the current behaviour.
    2. On discard cancel - redirects to node/x/layout (with changes still in tact)

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    aaron.ferris โ†’ changed the visibility of the branch 3427398-the-functionality-of to hidden.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    aaron.ferris โ†’ changed the visibility of the branch 3427398-the-functionality-of to active.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    aaron.ferris โ†’ changed the visibility of the branch 3427398-the-functionality-of to hidden.

  • Pipeline finished with Success
    3 months ago
    Total: 541s
    #119348
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rkoller Nรผrnberg, Germany

    Awesome, thanks for the MR! I've manually tested and confirm that the MR provides the functionality I've suggested in the issue summary and that it feels like the right choice when actually playing around with it on an install of 11.x-dev. The only question would it be necessary to provide test(s) for this MR as well?

  • Status changed to RTBC 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia adwivedi008

    Manually Tested the MR and confirm that it resolved the issues regarding the Cancel and Confirm button functionality so RTBC+ From my side.

    Changing the issue's status to RTBC, so that other people can also review and provide their suggestions.
    As mentioned by @rkoller not very sure about the test coverage.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    I checked the test coverage, unless im missing something (could well be) there is no coverage for the actual destination of these buttons.

    There's this:

        // Make and then discard changes.
        $this->assertModifiedLayout(static::FIELD_UI_PREFIX . '/display/default/layout');
        $page->pressButton('Discard changes');
        $page->pressButton('Confirm');
        $assert_session->pageTextNotContains('You have unsaved changes.');
    

    Also some bits and pieces around Discard->confirm, but not cancel.

  • Status changed to Needs work 3 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand DanielVeza Brisbane, AU

    Setting back to NW for test coverage.

    If there is no coverage for the cancel button at the moment, IMO we need a test in LayoutBuilderUiTest that does the following:

    1. Go to the default layout
    2. Update the default layout, add a section & a block
    3. Press the discard button
    4. Press the cancel button
    5. Assert the newly added section & block are still there
    6. Assert the address is the layout builder edit screen
  • Pipeline finished with Failed
    3 months ago
    Total: 188s
    #134632
  • Pipeline finished with Failed
    3 months ago
    Total: 527s
    #134635
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    Ive pushed an initial go at the test for this, it follows a similar approach to testUnsavedChangesMessage

    Will this suffice? Suggestions welcome.

  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris
  • Status changed to Needs work 3 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    May need a rebase.

  • Pipeline finished with Canceled
    3 months ago
    Total: 196s
    #135207
  • Pipeline finished with Success
    3 months ago
    Total: 602s
    #135212
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    Thanks @smustgrave - committed your suggestion and rebased. Back for review.

  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris
  • Assigned to DishaKatariya
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia DishaKatariya

    Hi, Can someone please add the propr screenshots of this issue? so that i can be able to reproduce it properly.
    Followed the given steps but changes are already looking fine to me as expected.
    Thanks.

  • Issue was unassigned.
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    Hello @DishaKatariya

    Ive added some screenshots that will hopefully help

    Thanks
    Aaron

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand DanielVeza Brisbane, AU

    I added a couple of thoughts to the MR. Nothing I feel super strongly about so leaving the status the same

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sdhruvi5142

    Hi, I've verified and tested MR! 7042 and applied patch successfully on 11.x Version the changes are working as expected.

    Following steps I followed:
    1. Open local and Go to /admin/structure/types/manage/article/display/default
    2. Activate Layout Builder
    3. Change the order of the default blocks to Tags, Body, Image, Comments
    4. Click the Discard changes button
    5. Click confirm
    6. Reapply the changes to the block order for the layout
    7. Click the Discard changes button again
    8. Click the Cancel button
    9. Observed the changes here

    Testing Result:
    After changing the orders of the default blocks and click on Discard changes button > Clicked on Cancel button and user was redirected back to the page of the layout so the user is able to continue with the already made changes. Hence the changes are working as expected.

    Attaching the videos for reference.

    Hence moving to RTBC!
    Thanks

  • Status changed to RTBC 3 months ago
  • Status changed to Needs work 3 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone New Zealand

    @sdhruvi5142, thank you for the manual testing.

    There are unresolved threads in the MR about the testing. This also should have a title that reflects what is being fixed.

  • First commit to issue fork.
  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    I've incorporated the new test into an existing test around the same functionality - which was missing a test of the cancel functionality.

  • Pipeline finished with Success
    3 months ago
    Total: 637s
    #138753
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom aaron.ferris

    Thanks @alexpott

  • Status changed to RTBC 3 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Couldn't run test-only feature due to gitlab roles so ran locally

    Behat\Mink\Exception\ExpectationException : Current page is "/admin/structure/types/manage/bundle_with_section_field/display/default", but "/admin/structure/types/manage/bundle_with_section_field/display/default/layout" expected.
    

    Can confirm applying the MR that discarding changes takes me back to the layout builder.

    Believe this change is good to go, title also reflects what is happening now.

  • Status changed to Fixed 3 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Committed and pushed 8c50a65a7d to 11.x and 828a3c56df to 10.3.x and eb9a102582 to 10.2.x. Thanks!

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

Production build 0.69.0 2024