Proposed commit message
Issue #1842140 by mdrummond, tonystar, gavin.hughes, killerpoke, lauriii, droweski, stevector, omg-its-maggie, jenlampton, Renee S: Remove title and wrapper div from theme_item_list.
Problem/Motivation
We are currently printing a title and wrapper div in item list templates. Templates really should be as concise and semantic as possible, and only print a div when it's really needed, the title should be a separate element. The class from the wrapper div can be moved to the ul/ol tag, and the CSS can be updated to match.
Proposed resolution
When we need a heading tag and/or a wrapper div, we should call theme_links instead. That theme function can then call theme('item_list') which will generate a nice clean list. When we only need a nice clean list, we can call this function directly.
Proposed code fo the item list template:
{% spaceless %}
{%- if list_type == 'ul' -%}
<ul{{ attributes }}>
{%- else -%}
<ol{{ attributes }}>
{%- endif %}
{%- for item in items -%}
<li{{ item['#wrapper_attributes'] }}>{{ item }}</li>
{%- endfor -%}
{%- if list_type == 'ul' -%}
</ul>
{%- else -%}
</ol>
{%- endif %}
{% endspaceless %}
Location of item_list call | Changes (this patch) |
---|---|
core/authorize.php | N/A |
core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php | N/A |
core/includes/theme.maintenance.inc | N/A |
core/modules/node/node.module | N/A |
core/modules/system/css/system.theme.css | CSS cleanup |
core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php | update tests to exclude title |
core/modules/system/system.module | Update CSS - classes moved to ul |
core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module | N/A |
core/modules/tour/lib/Drupal/tour/TourRenderController.php | Update CSS - id and class moved to UL |
core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php | N/A |
core/modules/views/lib/Drupal/views/Plugin/views/field/PrerenderList.php | N/A |
core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.php | Update CSS - classes moved to ul |
core/modules/views/views.theme.inc | Update CSS - classes moved to ul |
core/update.php | N/A |
Remaining tasks
- Remove the title from theme_links
- Move the class from the wrapper div onto the ul itself, and delete the wrapper div
- Update all CSS to reflect the new location of the class
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Reroll the patch if it no longer applies. | Instructions | ||
Update the issue summary | Instructions | ||
Update the issue summary noting if allowed during the beta | Instructions | ||
Embed before and after screenshots in the issue summary | Novice | Instructions |
User interface changes
None.
API changes
Call theme('links') when you need a wrapper div and/or a title.
Call theme(item_list) when you only need a list.
Related
#311011: Replace links.html.twig with item-list--links.html.twig
#2032645: Replace calls to theme('item_list') with calls to theme('links') for links, when a heading or wrapper div is warranted
#891112: Replace theme_item_list()'s 'data' items with render elements
#1777326: Replace theme_links() with theme_item_list()
#1910996: Update theme_item_list to call theme_ol or theme_ul
#1980004: [meta] Creating Dream Markup
Comment | File | Size | Author |
---|---|---|---|
#132 | remove_title_and-1842140-132.patch | 20.9 KB | Manjit.Singh |
#128 | remove_title_and-1842140-128.patch | 20.88 KB | rteijeiro |
#123 | remove_title_and-1842140-123.patch | 21.94 KB | lauriii |
#117 | remove-title-wrapper-div-theme_item_list-1842140-117.patch | 20.93 KB | akalata |
#109 | interdiff-107-109.txt | 1.35 KB | BarisW |
Comments
Comment #1
Renee S CreditAttribution: Renee S commented[edit: nevermind, heard access isn't being given anymore. will submit teeny patch :) ]
Comment #2
Renee S CreditAttribution: Renee S commentedTeeny tiny patch attached (I'm assuming this is for stark, yah? :)
Comment #3
Renee S CreditAttribution: Renee S commentedComment #4
killerpoke CreditAttribution: killerpoke commentedComment #5
killerpoke CreditAttribution: killerpoke commentedlooks good to me, but I'm not surre about the indention.
Comment #6
c4rl CreditAttribution: c4rl commentedI'm closing this since at this point we just need to get these converted to core, then refactor later. This is a core issue, not a sandbox issue.
Comment #7
c4rl CreditAttribution: c4rl commentedNevermind, I'm just going to move this into the core queue and revise the summary. Less duplication :) Will revise summary.
Related: #1910996: Update theme_item_list to call theme_ol or theme_ul
Comment #7.0
c4rl CreditAttribution: c4rl commentedadd templates affected
Comment #8
c4rl CreditAttribution: c4rl commentedJust a follow-up for the Twig sandbox folks, I'm removing ol.html.twig and ul.html.twig per #1910996: Update theme_item_list to call theme_ol or theme_ul, we'll follow-up there.
Comment #9
jenlamptontagging
Comment #10
jenlamptontagging
Comment #11
falcon03 CreditAttribution: falcon03 commentedThe title support should not be removed. It's there for accessibility: menus, in fact, are lists; and each menu needs a title.
Comment #11.0
falcon03 CreditAttribution: falcon03 commentedBetter summary
Comment #11.1
jenlamptonupdated issue summary
Comment #11.2
jenlamptonrelated
Comment #12
jenlampton@falcon03 if that's the case then menus should not be calling theme_item_list(), they should be calling theme_links() which has a wrapper div and title, or better, theme_menu(). See #311011: Replace links.html.twig with item-list--links.html.twig and #1834022: Combine theme_menu_tree and theme_menu_link, and rename theme_menu
edit: Also, since this is just a render array you can always add a #prefix to your render element containing the title if there's no better way to do it. :)
previous:
now:
Marking as postponed, this issue is blocked by #2032645: Replace calls to theme('item_list') with calls to theme('links') for links, when a heading or wrapper div is warranted.
Comment #13
jenlamptonhere's a go at cleaning up all the css - item_list is still a theme function, so this may need a reroll if it becomes a twig template soon.
Comment #14
dpintats CreditAttribution: dpintats commentedWorking on this alongside johnnydarkko, who is working on #311011: Replace links.html.twig with item-list--links.html.twig.
Comment #14.0
dpintats CreditAttribution: dpintats commentedcode up
Comment #14.1
jenlamptonlist of changes
Comment #15
jenlamptonunassigning.
Comment #17
stevectorHere's a reroll of #13 just to get it applying again.
Comment #18.0
(not verified) CreditAttribution: commentedup
Comment #19
jibran#17: drupal-clean_up_item_list-1842140-17.patch queued for re-testing.
Comment #21
Fabianx CreditAttribution: Fabianx commentedTagging for re-roll
Comment #22
gavin.hughes CreditAttribution: gavin.hughes commentedRerolled #17 :)
Comment #23
gavin.hughes CreditAttribution: gavin.hughes commentedUpdating status
Comment #25
gavin.hughes CreditAttribution: gavin.hughes commented#23: drupal-clean_up_item_list-1842140-22.patch queued for re-testing.
Comment #26.0
(not verified) CreditAttribution: commentedAdd dream markup meta to related
Comment #27
droweski CreditAttribution: droweski commentedPatch 22 will not apply to current code base.
Can apply at commit 5fccca655e90d9e7a557fda8d16dc2afab93ac08
I'm currently re-rolling patch against current.
Simpletest test failures look related to pager errors.
Comment #28
droweski CreditAttribution: droweski commentedRe-rolled patch against current code.
conflict was in core/themes/seven/styles.css
Couldn't get my interdiff to work.
I expect patch will fail testing but now we are at least up to date.
Comment #29
droweski CreditAttribution: droweski commentedComment #31
YesCT CreditAttribution: YesCT commentedneeds a reroll, https://drupal.org/contributor-tasks/reroll
Comment #32
RainbowArrayHere's a reroll from #28.
Comment #34
RainbowArrayI ran the render test that failed on my local dev with the patch applied, and the test passed. So, setting testbot to rerun this.
Comment #35
RainbowArrayErrr, sorry, wrong issue.
Comment #36
RainbowArrayHere's a reroll.
I'm not fully grokking the preprocess function: it seems to me like this will probably out the item-list class on list elements rather than ul or ol. But maybe I'm wrong.
Hopefully this is a better starting point to finish patching this up.
Comment #38
RainbowArrayNew attempt to set the item-list class on the list. This is probably wrong: we'll see if it's more or less wrong.
Also, we may want to change the scope of this issue. The header on the list is already optional in the item-list twig file. This patch just focuses on removing the wrapper div now. Probably the way to go.
Comment #40
joelpittetThis line is not needed at all, attributes are magic arrays to start and get converted to Attribute objects during drupal_render.
This would be nicer if it didn't have the element selector on it, can we say that all direct children with that class get the same style?
probably want to do .pager.item-list
This row_classes stuff is not right at all... should be row.attributes.
none of this should be in here.
Comment #41
RainbowArrayHere's a patch that addresses the issues in #41.
Comment #42
RainbowArrayComment #43
joelpittetnot quite, no need for the [id] in the loop. That code should not change.
Comment #44
RainbowArrayFixing an error with the attributes.
Comment #48
lauriiiMoving this forward. Someone could take a look for the visual changes
Comment #49
killerpoke CreditAttribution: killerpoke commentedI just review patch 1842140-48.patch. I rendered a test list and it looks the same, with and without the patch.
It looks good to me except, one:
You forgot to include changes to core/themes/seven/css/components/table.css
I created a patch that also includes table.css
I think, the only case, there is a side-effect, is when .item-list has a fixed width and a box-size model, that doesn't count padding to it's size. After applying the patch, .item-list element will be bigger then it's original size.
Comment #52
anydigital CreditAttribution: anydigital commentedSince the "ul" tag has already straightforward meaning we actually don't need special ".item-list" class here. For menu purposes we still have ".menu" class there.
Finally we found all the occurrences of ".item-list" in the Drupal core and got rid of them.
Title is still in the templates for compatibility reasons. Anyway it could be easily overridden in templates or even cut in the future.
All of this was done in agreement with mortendk and johnalbin.
Attached patch also fixes views markup.
Comment #53
anydigital CreditAttribution: anydigital commentedAnd let's not forget to add omg-its-maggie in the commit message!
She helped me a lot with testing, support and inspiration!
Comment #59
anydigital CreditAttribution: anydigital commentedFixed issues related to view_list template and tests.
Comment #60
anydigital CreditAttribution: anydigital commentedComment #62
anydigital CreditAttribution: anydigital commentedFixed XPaths in Views Field UI tests.
Comment #63
anydigital CreditAttribution: anydigital commentedComment #64
anydigital CreditAttribution: anydigital commentedGuys, please review!
Two things to note:
Comment #65
Fabianx CreditAttribution: Fabianx commentedThe patch looks great to me.
The test changes make total sense and tests pass.
A DivKiller issue, which is a nice cleanup overall.
=> RTBC
Comment #66
Fabianx CreditAttribution: Fabianx commentedComment #67
alexpottCommitted 7939567 and pushed to 8.0.x. Thanks!
Comment #69
RainbowArrayGetting rid of .item-list is a regression with D8's CSS architecture: https://www.drupal.org/node/1887918.
Now CSS is dependent upon a specific HTML element, ul, which isn't good if an ol is needed. If we were getting rid of the wrapper div, we would have been better off applying .item-list to the ul and using that in the selector rather than a ul element.
Nothing replaces these styles that are removed?
We're removing styles without any replacement here. Also, this is now applying styles to every single list item anywhere rather than to list items designated as part of an item list.
Again, context gone.
Context gone.
Again, this is now targeting all unordered lists inside of a table cell.
We should probably do a follow-up issue to make sure that we get this CSS in line with D8's CSS architecture.
Comment #70
joelpittetHmm this is a bit of a quick change for having such a large scope. This may need reverting, discussion and mostly screenshots of item lists changed.
I completely agree with the idea behind this, but the rigor in testing is missing. Since it's CSS there is no visual regression tests in core so we need eyeballs.
Comment #71
Fabianx CreditAttribution: Fabianx commentedWell, John Albin agreed, so we should ping him, before rolling back.
We are close to having visual regression testing working in contrib, fwiw.
We can add the ul item-list also back to classy, as core would not have that class anyway.
Ul,ol are lists - always, so that is redundant information.
I think the do not depend on elems is meant in another context, but need John to chime in.
Comment #72
Fabianx CreditAttribution: Fabianx commentedAssigning ...
Comment #73
joelpittetYou are right the class is quite useless but it seems people have given it meaning where there was none before. Using it to distinguish uls used for menus or in the body copy or in pagers vs ones generated by this function.
That "meaning" needs to be undone for this issue to be actually "fixed" which is why the rigor is needed.
Also see #2335003-23: Rename task-list.html.twig to maintenance-task-list.html.twig for a screenshot of the regression.
Comment #74
omg-its-maggie CreditAttribution: omg-its-maggie commentedAre you saying that it is ok to change the classname as long as it's a more sensible semantic name?
Because then I agree.
Comment #75
lauriiiDo we have to have item-list wrapper? Cant we use it as a class the way I suggested on #48?
Comment #76
anydigital CreditAttribution: anydigital commentedRight. That's why we executed something like
grep -r 'item-list'
throughout the whole code to fix everything.We made a basic tests after and everything looked fine but we used installed Drupal that's why we missed that one on the installation page.
***
It's kind of a "bug" in
maintenance-page.css
actually:This rule should be added also there:
***
I see only 2 potential problems which should be double-checked while deeper testing:
... div > ul
since we have no interjacent DIV anymore — this is not so easy to detect, but using such selectors are just wrong initially.So, I think we do it right way at all: we definitely don't need .item-list class here. What we need — is exploratory testing. And let's wait @johnalbin feedback of course.
Comment #77
star-szrIt sounds like in the meantime this should be reverted and then we can get a more thoroughly tested version in.
Comment #79
star-szrThank you @alexpott!
Comment #80
anydigital CreditAttribution: anydigital commentedComment #81
webchickAdding participants from #2351023: Bullets are showing in installer to the commit credit string in the issue summary, since they jumped in to fix one of the regressions created by this patch.
Comment #82
lauriii@tonystar: The site was visually broken also on installed site wherever .item-list was before that change used e.g. messages.
Comment #83
andrewsuth CreditAttribution: andrewsuth commentedRerolled and added the regression patch from #2351023: Bullets are showing in installer
Comment #84
andrewsuth CreditAttribution: andrewsuth commentedAdded missing interdiff file.
Comment #85
anydigital CreditAttribution: anydigital commentedComment #86
star-szrI think we should start adding URLs/steps to the issue summary where this can be tested. For example the search results uses an item_list theme suggestion.
Comment #87
tim.plunkettFixing tags.
Comment #88
droplet CreditAttribution: droplet commentedthese changes (and a lot on this thread) making the CSS less reusable and harder theming. It just making for the Drupal project, not for all custom Drupal projects. when you adding custom features, you also have to adding many CSS to override the widely pre-applied default style.
I'd suggest to limit the scope. adding re-use .class the ul lists...etc
https://smacss.com/book/type-module
Comment #89
Fabianx CreditAttribution: Fabianx commentedWe could try some visual regression testing using SiteEffect.io for this issue.
Comment #90
RainbowArrayThis CSS definitely needs to be fixed. There are a ton of style definitions that depend solely upon element chains, which doesn't fit with D8's CSS architecture. Defining all the behavior of every li everywhere is far too broad. Much better to have class selectors that are less likely to cause problems elsewhere. Having ID's in the selectors makes the specificity very difficult to override: it looks like that may have been there previously, though, so that may or may not be in scope to fix that for this particular issue.
Comment #91
ti2m CreditAttribution: ti2m commentedAs suggested by @fabianx I have tested the patch that got reverted, just to see what I would catch with the visual regression testing approach described in #2229187
I wasn't able to figure out yet if it is being considered ok for the patch to introduce visual changes. Meaning I'm not sure if e.g. the spacing between primary tabs is allowed to change or not. As siteeffect isn't public yet I just uploaded gifs to dropbox to give you an idea. The preview mode actually works quiet nicely with gifs:
https://www.dropbox.com/sh/xptxt6skjgi0mjj/AAAfR3MrRxQpE5hZpOEm8UqAa
I can post the urls to these pages if that helps.
Background on which pages have been tested: A fresh D8 install is being done with all modules enabled. Then for every page SiteEffect finds in its build in crawler, the menu router item will be looked up. Only three pages per menu router item will be analyzed. This way only three menu edit forms will be tested and not hundreds. The problem so far is though that no test nodes, comments or terms exist and therefore a lot isn't being covered. Working on it...
The test setup is not fully automated yet, so it always takes me a little while, but I'm getting there. If I can help with running more tests, maybe on the latest patch then let me know.
Comment #92
YesCT CreditAttribution: YesCT commentedlets get a beta evaluation for this normal task. added directions to the issue summary.
Comment #93
Vikas.Kumar CreditAttribution: Vikas.Kumar commentedI added patch, Please check.
Comment #94
Vikas.Kumar CreditAttribution: Vikas.Kumar commentedI added patch, Please check.
Comment #96
Manuel Garcia CreditAttribution: Manuel Garcia commented#94 is incomplete, rerolling...
Comment #97
Manuel Garcia CreditAttribution: Manuel Garcia commentedrerolled #83.
Comment #99
Manuel Garcia CreditAttribution: Manuel Garcia commented$expected wasnt reinitialized... oops!
Comment #100
Manuel Garcia CreditAttribution: Manuel Garcia commentedArgh left me debug calls in the last patch sorry.
Comment #102
manningpete CreditAttribution: manningpete commentedPatch applies
Comment #103
YesCT CreditAttribution: YesCT commented@Manuel Garcia Do not worry about the multiple patches. :)
Interdiffs would be nice when making changes after a patch that applies when getting tests to pass though.
For instructions on creating an interdiff, see https://drupal.org/documentation/git/interdiff
For example you could have made a interdiff.1842140.97.99.txt and interdiff.1842140.99.100.txt
it helps other people learn from your fixes, and helps reviewers.
Please let us be sure to get the screenshots and issue summary done while this applies and passes tests.
Comment #104
Manuel Garcia CreditAttribution: Manuel Garcia commented@YesCT true... I keep forgetting we can just use interdiff for this, will tattoo it on me forhead.
Comment #105
RainbowArrayGlad to see the rerolling. I think we still need to address the concerns I raised in #90 with using elements in the CSS selectors rather than classes, as that goes against our CSS architecture for D8.
Comment #106
BarisW CreditAttribution: BarisW at LimoenGroen commented@mdrummong; the patch replaces the logic with ID's as-is. This issue is targeted at removing the wrapper div, which it does. Can we add a follow-up to improve the css selectors?
Comment #107
BarisW CreditAttribution: BarisW at LimoenGroen commentedCore moves fast. Here is a re-roll.
Comment #109
BarisW CreditAttribution: BarisW at LimoenGroen commentedTry again, testbot.
Comment #110
star-szrRegarding #106: In my opinion, no. At this stage in the D8 release cycle, we really can't make D8 less shippable. Even ignoring that, we should follow our own standards.
Thanks for keeping on this @BarisW.
Comment #111
ti2m CreditAttribution: ti2m commentedI tested the patch in #109 again with siteeffect, looks lot more stable now. Some issues I found:
Comment #112
rteijeiro CreditAttribution: rteijeiro commentedHey @ti2m, it would be nice if you can provide some screenshots from your awesome SiteEffect tool to help to find the issues.
Comment #113
ti2m CreditAttribution: ti2m commentedHere are some screenshots, gifs don't work that well either. I think best might be to generate screenshots next to each other and highlight changed areas. Maybe this works for now if you download them and switch between them.
https://www.dropbox.com/sh/000977owkn9uuae/AAD3Pf8M4HqA-S96GzGenJ2ha?dl=0
Comment #114
akalata CreditAttribution: akalata commentedComment #115
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedRerolling
Comment #116
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedStuf taht was removed in core/modules/system/css/system.theme.css was now removed on core/themes/classy/css/components/item-list.css, but there are some styles left in there so someone should take a look.
As a matter of fact, please review everything to do with item-list.css both in bartik and classy.
I'm sorry but I messed up while rerolling so I'm not uploading the reroll. Will try getting to this at another time.
Comment #117
akalata CreditAttribution: akalata commentedPosting a reroll.
Comment #120
jibranMerge art effects
Comment #121
akalata CreditAttribution: akalata commentedthanks @jibran! I think you meant "artifacts" here, instead of "art effects" :)
I see what Manuel means in #116, reconciling the changes to Bartik's item-list.css and system.theme.css is making my head hurt!
Comment #122
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedYeah @akalata... i messed it up there as well... I'm pinging the fine folks on #drupal-twig in IRC to see if any of them can give us some information to reroll this properly. Will post here any findings.
Comment #123
lauriiiComment #126
rootworkThis is going to apply to EVERY
ul
element. Is that really what we want?Similarly the styles in the patch for
li
are going to affect all of them.This will also apply to every
ul
in Seven.div
, but why can't we move the wrapperdiv
's class -- item-list -- to theul
itself? That's what the issue summary says is supposed to happen.Comment #128
rteijeiro CreditAttribution: rteijeiro at Tieto commentedRe-rolled. Probably #126 should be addressed
Comment #131
Manjit.SinghComment #132
Manjit.SinghComment #143
jigariusI don't know if this is directly relevant to this issue, but title_attributes in the item list are lost before they reach the TWIG file.
Comment #152
andypost