Problem/Motivation
When working with the Block Layout interface, it's confusing to delete a block and be taken back to another theme's block layout page. This could cause users to accidentally delete blocks from another theme (thinking they belong to the theme they just deleted a block from).
Proposed resolution
This might not be the Drupal 8 way of doing things (since I just started diving into Drupal 8 Core recently), but for now I suggest we just add a destination query string variable to the delete operation that returns to the current page.
Remaining tasks
Attach the patch.
User interface changes
The interface itself does not change, it just redirects to a different location.
API changes
There are no API changes.
Data model changes
There are no Data model changes.
| Comment | File | Size | Author |
|---|---|---|---|
| #39 | interdiff-36-39.txt | 1.2 KB | krzysztof domański |
| #39 | core_2527628-39.patch | 2.81 KB | krzysztof domański |
Issue fork drupal-2527628
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
Comment #1
sammarks15 commentedHere's the patch that introduces the changes.
I just noticed the change is actually in the
EntityListBuilderclass. This shouldn't cause any problems with other parts of Core (since redirecting back to the page the user was on is the expected functionality in most cases), but I'm open to suggestions.I also updated the version to beta12, as that's the version I based the patch off of (I couldn't get the latest development version to run for testing).
Comment #2
sammarks15 commentedI noticed that the patch, when applied, causes one of the tests to fail. Could someone explain why I'm getting an error with the dependency injection? Here's the error that occurs in the test:
It stems from line 127 of
core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.phpComment #4
tim.plunkettGood find! We should add automated tests for this.
Comment #5
tim.plunkettI think instead of hardcoding 'current' we should consult the service, otherwise we'll override any current ?destination.
I've added test coverage for both cases.
Also note that the node and user listings already handled this.
Should we opt all entities into it, or just have block do it as well?
Comment #8
tim.plunkettI don't think it's appropriate to modify ALL of the entity list builders. They can opt-into this themselves.
Comment #9
tim.plunkettUghhh sloppy copy/paste (delete vs edit)
Comment #10
sammarks15 commentedCompletely agree with not automatically opting all entity list builders into it. I would have done that myself, except I didn't know the correct Drupal 8 way to do it :)
Comment #12
mgiffordPatch needs re-roll.
Comment #13
swentel commentedGot bitten by this one too - rerolled
Comment #14
chi commentedIs it worth to inject redirect.destination service into the BlockListBuilder instead of using the trait?
Comment #16
joachim commentedBlockDeleteForm already implements getCancelUrl(), so I think it's more elegant to return the right URL here than use a query destination string.
(It's getCancelUrl() rather than getRedirectUrl() because of #2712417: EntityDeleteFormTrait doesn't use its own getRedirectUrl().)
Comment #18
joachim commentedWeird. Tests pass for me locally.
Here's a reroll.
Comment #19
tim.plunkettThis should inject the service.
Might as well use ===
Comment #21
joachim commentedDone both of those.
(In true XKCD condiment-passing style, this is been the spur I needed to add support for injecting any service into forms generated by Module Builder!)
Comment #28
krzysztof domańskiTested manually. Currently, deleting a block redirect back to the correct theme! The problem was last reported in the version 8.2.
I added a patch with test coverage.
Notice: Not works when using domain language negotiation but there is an additional issue:
#2980527: Domain-based language negotiation strips "destination" URL query argument, causing BigPipe error
Comment #30
krzysztof domańskiComment #32
krzysztof domańskiImproving test
Url::fromRoute('block.admin_display') instead 'admin/structure/block'
Url::fromRoute('block.admin_display_theme', ['theme' => 'seven']) instead 'admin/structure/block/list/seven'
Comment #34
krzysztof domańskiThe last submitted patch, 32: core_2527628-32.patch, failed testing.
Similar problem #2986962: BrowserTestBase::drupalGet() does not appear to be handling base url properly
Comment #35
krzysztof domańskiComment #36
krzysztof domańskiRefactoring of deprecated code.
Comment #39
krzysztof domańskiComment #49
larowlanComment #50
bhanu951 commentedComment #52
bhanu951 commentedComment #53
smustgrave commentedThank you @Bhanu951 for the MR.
Appear to be some failures in the tests. Moving back to NW for those.
Comment #54
smustgrave commentedThis will need an issue summary update and title update. If the issue is fixed and this is just about adding test coverage then it should be stated.