Cannot discard layout builder changes with destination in URL query

Created on 8 September 2023, over 1 year ago
Updated 23 July 2024, 6 months ago

Problem/Motivation

When visiting a node layout builder page from /admin/content, and then clicking "Discard changes" button, the user is redirected back to /admin/content instead of confirmation page, and thus the changes are not discarded.

Steps to reproduce

Navigate to /admin/content
Click "Layout" action for any node
Click "Discard changes" button on the layout page
Get redirected back to /admin/content

Proposed resolution

Force redirect user to confirmation page.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Layout builder 

Last updated 2 days ago

Created by

🇨🇾Cyprus alex.bukach

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @alex.bukach
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    30,341 pass
  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    Thanks for reporting.

    Could use a small test case.

  • 🇮🇳India Abhijith S

    Confirming this issue exits in Drupal 10.1. as well.

  • 🇮🇳India Abhijith S

    Patch #2 updated with test case.

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    29,722 pass
  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States smustgrave

    Recommend using MRs

    Tried replicating this and I get redirected back to the node page, which seems correct.

  • Pipeline finished with Success
    about 1 year ago
    Total: 511s
    #68672
  • Pipeline finished with Success
    about 1 year ago
    #70526
  • Status changed to Closed: cannot reproduce 9 months ago
  • 🇳🇿New Zealand danielveza Brisbane, AU

    On a fresh D11 install I'm also unable to replicate this.

    Something else to flag is that on /admin/content on a fresh D11 install there is no layout action out of the box. So there may be a custom or contributed module that is interferring here.

    Since steps to replicate were asked for over 3 months ago and nothing has been provided I'm marking this issue as closed. If you're able to provide steps to replicate please feel free to reopen or add a new issue.

    Thanks!

  • Status changed to Needs review 7 months ago
  • 🇨🇾Cyprus alex.bukach

    @DanielVeza I am still able to reproduce it on a fresh Drupal 11 setup. Here are the steps:

    • Navigate to a page /node/[nid]/layout?destination=[destination].
    • Click "Discard changes".
    • Get redirected to the [destination] page instead of /node/[nid]/layout/discard-changes

    Here's an updated patch.

  • 🇨🇾Cyprus alex.bukach

    Here's the correct patch.

  • Status changed to Needs work 7 months ago
  • 🇺🇸United States smustgrave

    Will need to be an MR and have test coverage too

    Thanks

  • Pipeline finished with Success
    7 months ago
    Total: 888s
    #211829
  • Status changed to Needs review 7 months ago
  • 🇨🇾Cyprus alex.bukach

    Here you are @smustgrave!

  • Status changed to RTBC 7 months ago
  • 🇺🇸United States smustgrave

    Thanks removing tests tag with coverage here https://git.drupalcode.org/issue/drupal-3386094/-/jobs/1999033

    Summary appears to be complete and manual testing proves it works as advertised.

    LGTM

  • 🇳🇿New Zealand danielveza Brisbane, AU

    Ran the tests only feature since I couldn't replicate this in #9. Test fail as the steps to replicate have described, so I expect that was an issue in my local testing.

    Code changes look good, I was debating if we should add a $this->getRequest()->query->has('destination') check around it, but since no other processing is being done to the destination I think it's safe to just run the remove.

    $this->getRequest()->query->remove('destination'); does an unset of the param passed, if it doesn't exist there should be no issue.

  • Status changed to Needs review 6 months ago
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Left a question on the MR

  • Status changed to RTBC 6 months ago
  • 🇺🇸United States smustgrave

    @larowlan believe that is correct. Way I understand is that the discard button is taking you back to /entity_test/1/layout vs /admin/content

  • Status changed to Needs work 6 months ago
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    The text only fail isn't going to admin/comment is what I'm saying

Production build 0.71.5 2024