Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
To support the expected user interaction in #2739079: Reduce visual clutter of Place Block module we need to be able have the block at least show up at the top of the region.
In general, we want to be able to place a block at an arbitrary place in the set of blocks in the region.
Proposed resolution
The 1st place block modal goes to a link like:
/admin/structure/block/library/bartik?region=content
Add support for a weight query string. In the controller pass the query string along to the second modal at a path like:
/admin/structure/block/add/search_form_block/bartik?region=content&destination=/admin/structure/block/library/bartik
Add a hidden input to BlockForm and poppulate it from the query string, and make sure it's an int in validate/submit
Remaining tasks
Patch
Tests
User interface changes
none
API changes
none
Data model changes
none
Comment | File | Size | Author |
---|---|---|---|
#13 | increment-2787641-13.txt | 4.86 KB | pwolanin |
#13 | 2787641-13.patch | 4.64 KB | pwolanin |
#9 | increment-2787641-9.txt | 3.89 KB | pwolanin |
#9 | 2787641-9.patch | 6.29 KB | pwolanin |
#5 | increment-2787641-5.txt | 2.34 KB | pwolanin |
Comments
Comment #2
xjmComment #3
pwolanin CreditAttribution: pwolanin as a volunteer commentedQuick start. NR for bot only.
Comment #5
pwolanin CreditAttribution: pwolanin as a volunteer commentedWas setting the weight into the settings which is not needed.
How about this.
Comment #6
pwolanin CreditAttribution: pwolanin as a volunteer commentedLooks like this is working. Just needs some test coverage now.
Comment #7
Bojhan CreditAttribution: Bojhan as a volunteer and commentedYes! Can we get a screenshot?
Comment #8
pwolanin CreditAttribution: pwolanin as a volunteer commented@Bojhan - screenshot of what? All it's doing it manipulating the query string at this point and using the data in the form. A follow-on would leverage that to make block_place work more consistently.
Comment #9
pwolanin CreditAttribution: pwolanin as a volunteer commentedSome test coverage for the weight query string, plus a test that all the expected regions are in the block admin UI. The latter is just a bonus (I started there but then found a better place to add the weight test).
Comment #10
pwolanin CreditAttribution: pwolanin as a volunteer commented@Bojhan - this is the follow-up issue that will make the small UI behavior tweak: #2791305: Set block weight during Place Block flow so it's always at the top
Comment #11
pwolanin CreditAttribution: pwolanin as a volunteer commentedComment #12
YesCT CreditAttribution: YesCT commentednot a sentence. oh, I see this is the pattern in this method already. ok.
this seems like an unrelated improvement.
oh, these are the only two values... maybe add zero, zero sometimes is a "funny" special case.
this assert seems like a sanity check, and not anything to do with the weight.
are these two asserting the same thing? that the weight query is in the link?
this test was copied from testAddBlockFromLibrary(), so that's where this comment came from, but I think the point in this test, is to ensure it has the weight, not only that it was created.
this seems like unrelated improved test coverage, separate issue.
Comment #13
pwolanin CreditAttribution: pwolanin as a volunteer commentedOk, removed the "extra" test method and addressing other comments.
Comment #14
YesCT CreditAttribution: YesCT commentedI looked at every line changed in the patch, and discussed things with @pwolanin in IRC.
I think the changes here are now within scope (though related issues would be nice for the removed improvements)
and make sense to me.
Also looked at https://www.drupal.org/core/d8-allowed-changes#beta
allowed changes in beta, and I think this is 8.2.x because either
"minor API additions or ..., if the impact outweighs the disruption"
or
"Certain other issues with high impact and low disruption at committer discretion only."
so... good from me for now, rtbc.
Comment #15
pwolanin CreditAttribution: pwolanin as a volunteer commentedThis probably needs a trivial re-roll since #2791335: Optimize repeated method call in PlaceBlockPageVariant::build, use service instead of direct query string went in a changed a line within the diff context.
Comment #16
pwolanin CreditAttribution: pwolanin as a volunteer commentedactually - never mind - BlockLibraryController also needs the optimization to move the destination call out of the foreach, but there is no conflict with the patch that went in.
Looks like this patch still applies fine at the moment.
Comment #17
alexpottIs this enough? When ordering blocks in the current block UI we also change the weights of the surrounding blocks.
Comment #18
tim.plunkettJust retitling to hopefully cut down on confusion.
Comment #19
pwolanin CreditAttribution: pwolanin as a volunteer commented@alexpott - this patch should be sufficient to enable putting a new block always at the top (or bottom). that bit is implemented in the follow-up patch.
This alone might not be sufficient to place a new block arbitrarily within the middle of existing blocks, since they might need to be shifted as you say.
Comment #20
tkoleary CreditAttribution: tkoleary at Acquia commented@pwolanin
Re: #2739079: Reduce visual clutter of Place Block module
The fact that this patch has no visible UI change does not ipso facto imply "we don't need to look at a design". The attitude that we can write the code and 'paint it with some UX' after the fact is a recipe for wasted effort and technical debt.
Different designs imply different data models. Imagine, for example that we had a design that included a button to 'maintain relative position' when moving a block from one region to another eg. based on the blocks visible to the current user, if in region A, block 1 is third from the top, when I move it to region B, it should still be third from the top. That's not a feature I'm currently designing, but if it were I'm pretty certain that this patch would need major refactor to handle it.
Comment #21
pwolanin CreditAttribution: pwolanin as a volunteer commented@tkoleary - please look at the patch. Your comments don't make sense. There is no change to the data model. This is only applied to new blocks.
Comment #22
YesCT CreditAttribution: YesCT commentedSee #2793053: Optimize repeated method call in BlockLibraryController for the destination optimization that was descoped in #13 (see interdiff)
(rerolls should be "easy" on either issue, context lines kind of thing.)
Comment #23
tkoleary CreditAttribution: tkoleary at Acquia commented@pwolanin
Spoke to Emily in UX meeting and she's confident in the direction, so I'll take her word for it.
Comment #26
xjmThanks everyone!
@tkoleary, this patch has no impact on the UI whatsoever (nor the data model, which also has nothing to do with the UI anyway. Data model ≠ data modeling tools.) There's nothing to "paint with UX" because it's just internal API support for future feature additions to the form workflow for placing blocks. Any followups that actually add/change the UI will of course need some usability review according to their module stability (minimal validation in the case of Place Block).
I think @alexpott's question is addressed by the comments above; I agree with @pwolanin (and the retitle) that this functionality is sufficient for now. If we need more later, we can add it then.
This is a BC addition to internal form functionality, so beta-safe. I checked with @tim.plunkett as a subsystem maintainer for both Block and Form API and he signed off on the change. My one question was whether we should document this request option, but according to @tim.plunkett we don't do that elsewhere either.
Committed ea28d66 and pushed to 8.3.x and 8.2.x. Thanks!
Comment #27
pwolanin CreditAttribution: pwolanin as a volunteer commentedThanks xjm! will wrap up the follow-up issue