Problem/Motivation
Sections are currently given numbers by their order. Section 1, Section 2, etc.
As a more complex layout can be built by combining many simple layouts, it would be nice to be able to give meaningful names to these sections.
These would only be shown when editing the layout, never on the front end.
Proposed resolution
Add ability to give sections names.
For now, this will only be used when the numeric version of the section is display: the remove section and configure section forms, and the visually-hidden parts of the UI used by screen readers.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#29 | 3073872-label-29-interdiff.txt | 2.35 KB | tim.plunkett |
#29 | 3073872-label-29.patch | 36.69 KB | tim.plunkett |
#29 | Edit layout for Article content items Drupal 2019-08-22.png | 57.21 KB | tim.plunkett |
#26 | lb-configure-block.png | 46.73 KB | webchick |
#26 | lb-unpatched.png | 41.41 KB | webchick |
Comments
Comment #2
tim.plunkettNote that there is a good deal of indenting in the patch, so I've attached a version using -w
Comment #4
tim.plunkettFixing existing tests. Still needs dedicated tests
Comment #5
tim.plunkettAdded tests, and fixed it so it doesn't say "section Section 1".
Comment #7
tim.plunkettFixed the way settings are stored and retrieved.
Comment #9
tim.plunkettOkay should pass now.
Comment #10
starshapedFirst pass at adding CSS to style the label.
Comment #11
starshapedRemoved an unrelated edit and rolled the patch again.
Comment #12
starshapedDisregard #11 -- the file I removed actually is relevant! The patch in #10 is the correct one.
Comment #14
tim.plunkettHere's an update to include the blocks part too. This will fail tests for sure. Interdiff against #10.
Comment #16
tim.plunkettOkay so the scope of this issue was just about allowing administrative labels to be customized. And they are used for the aria-labels and visually-hidden text, as well as the form titles for removing and configuring a section.
Removing all of the additional UI improvements, which should be done elsewhere (likely in contrib, first).
Interdiff against #9.
Comment #18
tim.plunkettFixed some tests
Comment #19
phenaproximaI was thinking this might get easily confused with the label of the layout plugin itself, but on second thought, this is very clearly part of the plugin settings, so it makes sense where and how it is. 👍
I was going to ask why this was needed, since we get it from FieldItemList, but I see it's because of the type hint. So, 👍
I think this comment needs to be expanded a bit. Why would the sections be out of date?
Not exactly sure what's going on here, but I assume it's just diff weirdness. 🤷♂️
This could use a comment. Why can't we call $this->getLayoutSettings() anymore? Will it not return the same data it previously did? If not, isn't that a backwards compatibility issue?
Why did these change?
And here? I must be missing something.
How about this? It's not clear why this changed...
This could also use a comment, maybe.
Comment #20
tim.plunkett3)
Rewrote the comment. The loop is needed to add in default values for the layout settings.
4)
MultiWidthLayoutBase was providing an empty validateConfigurationForm method, but now that is provided by its new parent class.
5)
From the diff it looks like it needs a comment, but if you read the code as-is, not as much. Also if someone tried to switch it, they will find out quickly why it needed direct access: getLayoutSettings() now calls to getLayout(), this method :)
6)
In HEAD the onecol and fourcol layouts had no settings, so they bypassed the configuration route. Now they have the label to configure, hence the change to the expected route.
7)
Same as above, we need to assert for the absence of the correct link. To be safe, I just asserted that neither /add/ nor /configure/ are used.
8)
There's no such plugin as
layout_default
, and now it is instantiated. Same for the other places this switches tolayout_onecol
.9)
Copied the relevant comment from feedback point 3
Comment #21
tim.plunkettIncluded post_update hook for the schema change
Comment #22
phenaproximaI gave this a quick manual test. It worked beautifully; the sections can indeed be assigned administrative labels, which are exposed as the title of the off-canvas area when configuring or deleting the sections. Well done! Code is clean and well-tested (par for the course with a @tim.plunkett patch), and we are accounting for the update path. I don't think this needs anything else.
Screenshots attached from my testing (on a clean new install).
Comment #23
phenaproximaForgot to move to RTBC.
Comment #24
webchickOk, running this through WebchickTestCase™!
First question: Can we smoosh the layout selection + the admin label into the same form so it's one step instead of two? We ideally want adding a section to be as quick and painless as possible; this new second step adds friction. (Oh, I see... this happens only for one-col; the other ones already have an extra configuration step. Well then.)
Second question: Why do I not see the section label I just created on the page anywhere? This left me fairly disoriented, especially with a one-column section where it's lots of equally-sized boxes stacked on top of each other. Would expect to see the "Configure" link say "Configure Top Header Thingy" or whatever. This would also help with targeting drag-and-drop.
(Oh wait. After dragging a block in, the labels suddenly appeared? Some caching issue? It's visible in @phenaproxima's screenshot at https://www.drupal.org/files/issues/2019-08-16/3073872-label-new-section... nevertheless, so don't think it's just me.)
At least in Firefox, there is also some weird styling on optgroups on the move drop-down. Probably a pre-existing condition, tho:
Elsewise the patch itself looks very straight-forward, has ample test coverage, and so on. A nice accessibility and usability improvement both, so \o/ Feels like we need to address that weird label disappearing issue, however.
Comment #25
webchickOk, spun off #3076153: Off-canvas dialog <optgroup> styling in Firefox is illegible for the third point.
On the second point, which is the only thing we need to fix here, I figured out through talking with @tim.plunkett that this is not a caching issue; rather, those labels are only visible when in keyboard navigation mode (which I also was testing).
We discussed and agreed that showing them is better though, because otherwise it gets confusing, esp. if you are creating multiple similar-looking sections at a time, as to which is which.
Since this is a new feature that not all sites will be using right away, what we discussed was conditional logic like (blatantly stolen from @tim.plunkett :D):
This way the labels are exposed to screen readers/keyboard users no matter what, but folks who don't need/want to use section labels aren't inundated with a bunch of "Section 1, 2, 3 [...]" in the UI.
Comment #26
webchickMoar feedback from the UX meeting today. :)
HEAD:
This patch:
This won't fly, because without the extra input as to what you're configuring, it's not clear what that configure link actually refers to. Additionally, the "X" icon seems to be associated with Configure, vs. its own operation. :O
This is particularly apparent when a section has blocks in it:
Absent of the word "section," a sensible person would think that these were links to configure / delete the content within the section, since that's what's actually visible.
All of that makes sense, but then seems to make the proposed resolution not quite right... instead we probably ought to instead just always display the section name even if it's an auto-generated delta (which has the side benefit of making the UX consistent between screen reader users and visual users).
In other words:
...across the board.
(Obviously with translation and escaping and such :P)
Comment #27
tim.plunkettFirst off, definitely agree with showing more text, not less. Will fix.
One clarifying question.
Let's say you have three sections.
You configure the label of the top section to be "Header section".
You do not configure the middle section label.
You configure the label of the bottom section to be "Footer".
By the current logic, it will say
"Configure Header section"
"Configure section 2"
"Configure Footer"
Note the mismatch between the first and third.
Or, we could have it say
"Configure section Header section"
"Configure section 2"
"Configure section Footer"
I'm partial to the first option, but just wanted to call it out.
Comment #28
webchickYeah, I think the first one is sufficient. As @yoroy always used to say, use
fewerwords. :) The previous concern was the standalone "Configure" getting confused with blocks, but I don't see that happening with the labels exposed.Comment #29
tim.plunkettDone!
Comment #30
phenaproximaSeems legit.
Comment #35
webchickGreat stuff! Thanks a lot for the extra tweaking!
Committed and pushed to 8.8.x, woohoo! Also crediting folks on the UX call, who contributed to the solution outlined here.
Comment #37
webchickAlso, probably something to mention in the release highlights reel. This is a nice feature for accessibility and usability both.
Comment #39
brooke_heaton CreditAttribution: brooke_heaton as a volunteer commentedNow that we've added the ability to add Administrative labels - how do I get rid of them :/ I find them super belittling to the end user.