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.
Task
Convert the following theme functions to use the new table #type:
Module | Theme function name | Where in Code | What is it really? |
---|---|---|---|
simpletest | theme_simpletest_test_table | function | table |
Related issues
Comment | File | Size | Author |
---|---|---|---|
#72 | table.simpletest.72.patch | 28.23 KB | sun |
#68 | table.simpletest.68.patch | 28.31 KB | sun |
#66 | table.simpletest.66.patch | 28.3 KB | sun |
#59 | Testing___Site-Install_and_Testing___Site-Install-5.png | 222.11 KB | joelpittet |
#54 | interdiff.txt | 1.91 KB | sun |
Comments
Comment #1
joelpittetSeem to have the same issue as
http://drupal.org/node/1876712#comment-7156742
Comment #2
jibran#1948374: #type 'table' allow attributes on table cells is in so I think we can unpostpone this.
Comment #3
star-szrGoing to see if I can something rolling on this over the next week or so.
Comment #4
joelpittet@Cottser, headstart... maybe. The following patch doesn't work in it's current state but most of the pieces are there for this table to work.
I ran into trouble because the checkbox fields weren't rendered yet so they don't have an #id to add to the JS so I started trying to mimic the way they are created. I think because of the JS, also the input fields for the groups don't show.
Hope that helps.
Comment #5
star-szr@joelpittet - Yeah, I didn't get as far as you did working on this tonight but I did figure out that the #id thing would be an issue and had things moving in roughly the same direction as you did :)
Thanks, will see if I can bounce it back in a day or two and push things along further.
Comment #6
joelpittetI think this should get the sorting working without a second loop. And something I did here made the checkboxes pop-in and toggle correctly as well. Though I have a feeling without the FAPI processing things won't act the same on form submit/validate for which items were previously open.
Comment #7
star-szrShould have time for this again over the next few days.
Comment #8
star-szrFirst a reroll, small conflict with #1846172: Replace the actions API.
Comment #10
star-szr#8 contained some additional changes, here is the actual reroll of #6 with -do-not-test, and an interdiff for the few changes between #6 and #8.
Edit: Okay the patch here is the same as #8 but the interdiff is legit so leaving it at that.
Comment #11
star-szrSigh. I was working from old local branches and somehow was basing my work on #4, not #6. So please ignore everything from #8 to #10 :)
Here is a proper reroll of #6 which seems to be working pretty well locally. The only thing I've noticed so far is that the for attributes on the labels do not match up, so clicking on the test names does not toggle the checkboxes. For now let's see what testbot thinks though.
Comment #12
star-szrGetting markup and functionality a bit closer. Will be back to this in a day or two.
Thanks to @joelpittet for the help on IRC tonight :)
Comment #13
star-szrComment #14
star-szrGetting markup a bit closer :)
Comment #16
joelpittet#14: 1938926-14.patch queued for re-testing.
Comment #17
joelpittetHell yeah green! Wicked @Cottser!
Comment #18
star-szrNew patch, separated into two interdiffs:
(And provided a combined interdiff as well.)
I did markup comparison via view source and running a visual diff and couldn't spot any differences.
Had some trouble during markup comparison with memory running out so I decided to do some profiling. Not sure how much of this is the patch and how much is #type table conversion overhead in general but this 35.9% wt increase looks very high to me, particularly because before the patch the page already took over 2s to render on my machine. Lots of calls to drupal_html_id() that add up quickly. I tried a preg_replace() and str_replace() version and it didn't fare much better. Suggestions and patches welcome, not sure when I will get back to this and IMO this should not be committed with such a large performance regression.
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ba929760d1b&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ba929760d1b&...
Comment #20
star-szr#18: 1938926-18.patch queued for re-testing.
Comment #21
jibran#18: 1938926-18.patch queued for re-testing.
Comment #23
joelpittetTagging, needs reroll
Comment #24
pplantinga CreditAttribution: pplantinga commentedReroll
Comment #25
star-szr@pplantinga, thanks for working on this! I think the reroll is missing some changes. I suggest a fresh reroll from #18.
#18: 3 files changed, 128 insertions, 128 deletions.
#24: 2 files changed, 128 insertions, 9 deletions.
Comment #26
pplantinga CreditAttribution: pplantinga commentedOops, thanks for catching that.
Comment #27
joelpittetRe-rolled.
Comment #28
jibranSome minor issues.
This should be render array.
This should be converted to attach.
Comment #29
joelpittetConfirming the results from #18
Postponing this issue until we find a way to get type #table faster.
Profiler output
Profiler output
Comment #30
moshe weitzman CreditAttribution: moshe weitzman commentedIs there an issue where we are improving #table performance? Seems like a fixable problem - we aren't trying to do anything different from the old way.
Comment #31
joelpittet@moshe weitzman there is not, but I was going to open one from #2152193: Discuss the fate of #type table
Comment #32
sunRe-rolled against latest HEAD + revamped to properly use #type table.
Doing so revealed a bug in form_process_table(), which does not ensure to use a custom #id for the tableselect checkbox, and thus, FormBuilder creates a second #id via drupal_html_id(), which then has a '--2' suffix.
Manually tested the test overview page, tableselect + custom group select, as well as instantfilter.
Let's move forward here as quickly as possible. The performance of #type table can only be fixed after all instances of #theme table are gone.
Comment #35
sunok, ok, then the other way around :)
Comment #37
star-szrThat's understandable but I don't think we can just push through the huge performance regression here. While it's great that we have so many tests that it's becoming a performance issue, we can't expect everyone to run tests through the CLI. If this is committed we're going to see a lot of folks reporting out of memory errors (check the peak memory usage increase) on /admin/config/development/testing and I can only see that turning in a revert.
One possible way forward would be to convert everything in a sandbox and do performance optimization there, then bring it back to the core queues once performance is acceptable.
Comment #38
sunSorry, this one should finally pass.
form_process_table() did not account for the case of #type table that wants to use #tree FALSE. (it defaults to TRUE for #type table, since that is the most common case)
Comment #40
joelpittetThanks for giving this a crack @sun
Re #32
Seems like this removes the first column and each
th
class as well. Was this intended?Comment #41
sunAbsolutely yes :)
One of the first and foremost reasons for introducing #type table was to combine several other, super-hard-to-grok alternative concepts into a single API.
Just specify
'#tableselect' => TRUE
for the #type table element + for the form submit buttons that need a selection. → Done.All magic happens under the hood. The table gets a first column containing form controls, and your form receives the values that you'd naturally expect. :)
→ We're not only going to reduce #theme table to the max, we will also #1876714: Remove #type 'tableselect'
So regarding #type table and performance concerns, there really is only one direction to accomplish the mission: (1) Convert everything. (2) Refactor/revamp #type table as one and only entry point for structured tables to gain optimal performance.
It is no surprise at all to me that individual conversions to #type table are showing a substantial performance decrease. → Just have a look at what that funky #theme table is actually doing. #theme table is one of the oldest theme functions and call chains in Drupal core since... Drupal 4.7?
There's no way to optimize that as long as there are two completely different entry points to the API for building and rendering a table via structured data. Kill the legacy crap first. Then refactor the modern way.
Lastly, those 'simpletest_' table header classes are completely obsolete and unused, hence removed.
Comment #42
joelpittetWell if #type=>table is meant to replace #theme=>table couldn't we just remove the theme_table call back and provide the proposed performance improvements directly on to #type table. That way we'd avoid the problem where people use #rows and bypass the element restructuring and the duplicate looping/restructuring preprocess?
They aren't unused: @see simpletest.module.css
Comment #43
sunThanks for catching that. I swear I had grepped the CSS for "simpletest_" before already, but somehow missed that instance.
Attached patch should pass all tests.
Comment #44
moshe weitzman CreditAttribution: moshe weitzman commentedI agree that we have to proceed here in order to unblock theme system DX. Once this goes in, I will track the reported performance regression at #1744302: [meta] Resolve known performance regressions in Drupal 8
Comment #45
joelpittetThe good news: Testbot passes, JS filtering still works as it did, and form submits correctly. So this is pretty close to RTBC but not quite there.
Markup changes that need some work:
Removed on purpose? Seems to be user feedback if tests aren't selected on submit.
Love these:)
Performance
Without the patch:
With the patch:
And just a visual difference, the page loads exactly 1s slower in yslow, which matches up to the difference in the ab test.
Comment #46
sunre: #45:
re: annotated diff screenshot:
Now, attached patch additionally fixes an accessibility problem with #type table:
The tableselect form elements (checkboxes/radios) are currently not associated with their actual/proper labels.
In a #type table with #tableselect, usually the first (second) table column holds the title (label) for the selectable option. However, that label is not associated with the form control. Instead, the form control is rendered with an invisible label:
To fix this, I'm introducing a new #type label, which essentially just wraps theme_form_element_label(), and which is used by the #tableselect processing to automatically associate the proper label for each item in the table, so that the result is this:
→ Works like a charm, fixes accessibility of #tableselect, and even reduces page size.
Note that "aria-labelledby" is not misspelled:
http://www.w3.org/TR/wai-aria/states_and_properties#aria-labelledby
Comment #47
moshe weitzman CreditAttribution: moshe weitzman commentedThis is RTBC for me, but perhaps @joelpittet has some final input.
@joelpittet - awesome annotated screenshot. I love the red/green numbered comments, and the highlighted source code. How did you make it?
Comment #48
joelpittetre #46 I'm good with all the changes and rational except for these two:
I'm positive this should still be in there, the implementation may need to change/move and I'm fine with that but the end result should likely be similar and not lost.
I agree the div is superflous but the class provides a UI heirarchy change. The .description text is used to demote in the visual hierarchy, in this case the text is lighter and slightly smaller. Can we just add that class to the wrapper?
Also, I like that the label changes! Makes much more sense now thank you for that. I'm not super happy with that whole themeable #types implementation with $element = $variables['#element'] being littered through out the theme functions but that's a different problem. (read ranty, rant rant). Nevertheless I'll split my consolidation of form_element_label theme as it is probably the path of least resistance right now to allow for this #type label bit. Thanks for bringing up this use-case for it... tables FTW? :P
@moshe weitzman thanks, it's just Skitch 2 + Sublime 3 (itg.flat.dark.green.sublime-theme at the moment).
Comment #49
joelpittetAlso, just realized crap! that .description class is targeting the div selector... well maybe we just add those styles to the description selector class that is already on it? the css class selector shouldn't be targetting like that but needs cleanup. Maybe just:
The margin & line-height don't help.
Comment #50
sunCould you please elaborate on what you're missing? I'm happy to explain how #type table + #tableselect + Form API works, but I don't know what your technical experience level on these topics is, so I don't know where to start.
The end result is the same as before: If no items are selected, Form API throws a form validation error that informs the user that no items were selected and no tests are run.
A few thoughts on that:
(would have the nice potential of possibly getting rid of .fieldset-description and .details-description, too)
Comment #51
joelpittetRe #50
<div class="description>
is to be dropped, the style for the developer experience's UX should not lose out on the deal. So the end result is either: add the styles in #49 in the css files, or add the<div class="description>
back in.('No test(s) selected.'), 'error');
Right now, the current patch in #46 no longer has user feedback when no tests have been selected after submit.Comment #52
sunSorry, I finally understood now that you were trying to report a bug "When I do not select any items, I do not get an error message." - That wasn't clear to me; I thought you were talking about the message string of the error message.
→ Fixed now. I had previously tested that and it worked, until I adjusted #type table to account for #tree FALSE to fix the Simpletest module test failures... However, the tableselect form elements cannot live at the top-level of a form, because the form validation handler of the parent #type table element is not able to determine whether any input was submitted otherwise. Added corresponding docs for that.
Comment #54
sunSorry, forgot to clean up one detail:
Moved stale help text into an actual hook_help() text.
Comment #56
sun54: table.simpletest.53.patch queued for re-testing.
Comment #57
sunRandom testbot OS failure. The new/final patch is green.
Comment #58
joelpittetGreat!
Comment #59
joelpittetSorry, one more thing I noticed the collapsible fieldset got dropped. Though this usually wouldn't be a huge issue, it's kinda nice to collapse the set from the top so you can get at that annoyingly placed "Clean environment" button. If possible it would be nice to leave that in.
Comment #60
sunAs briefly mentioned in IRC:
In short, I think the current patch not only converts to #type table, it also fixes the accessibility of #type table in general, and on top, it fixes the UX/usability of the main interaction of this page in accordance to our usability guidelines. Let's move forward :)
Further improvements to Simpletest's UI are very well possible and if you have any ideas, I'd be more than eager to hear + help!
Regarding front-end and total RTT performance, the next best step for this page is to get rid of 99% of the JavaScript settings, which are apparently duplicating ~40% of the page content in JSON, whereas there is absolutely no reason for why the JS on this page should need any kind of settings. Eliminating that would be a wonderful contribution. :)
Comment #61
jibranI think we need two core committers in this issue for UX changes @webchick and for performance regression @catch.
Comment #62
joelpittetI can suck it up and use the "end" key on my keyboard for now, but maybe we can get that button in a better position in a follow-up? I didn't really notice that toggle "feature" until I tested it anyway, always just gripped in my head at it being at the bottom as I abused my scroll wheel.
Re: the 'details' tag, I agree that may be the intended use-case but if that's how we do the collapsible UI then, it doesn't matter the tag (unless there is another UI element that does collapsible elements that isn't details tag, then we can just use that) It's not the tag's fault we used it for that UI feature...
Also agree with @jibran two committers would be nice:)
This is back to RTBC, thanks for addressing the questions and hopefully we can do that UI regression/improvement in a follow-up.
Comment #63
sunThanks! :)
And, sorry, as the original author, I can't leave that statement without correction:
Support for the HTML5 Details element was explicitly added in Drupal 8 to replace our previous "collapsible fieldsets" with a clear and concise user interface design component and concept (which isn't invented by Drupal):
#1168246: Freedom For Fieldsets! Long Live The DETAILS.
This particular HTML element has a (semantic) meaning. Any usage that does not comply with its meaning not only violates the Drupal user interface and usability guidelines, it also violates HTML5 standards.
The situation that Drupal core is still using details elements in (too) many places is solely caused by the fact that it was not possible to evaluate every single instance and usage of all former collapsible fieldsets in the conversion. → Just because a form in core happens to contain a details element right now does not mean that its usage is correct.
In fact, as far as I can see, progress on the full conversion + individual UI evaluations still appears to be in the same state it was when I took a break from Drupal core a year ago:
#1852104: #type details: Remove #collapsible property
#1892182: #type details: Rename #collapsed to #open
#1839158: Replace collapse.js with a proper polyfill for <details>
Not sure if/when I'll find time to work on that, but thanks for the reminder! :-)
Comment #64
joelpittetThanks for pointing me to that, another issue to lurk on, I like that #open. Still stand by my statement. If there is a need for collapsible elements and details is not the correct tag for the job, then maybe we need a div based one. This is not a good example as the UI just needs to change... but I'm sure there is a case out there, anyway contrib can deal with that or they will just abuse details as we did here:)
Comment #65
alexpotttable.simpletest.53.patch no longer applies.
Comment #66
sunSimple diff context conflicts, clean merge.
Comment #67
alexpotttable.simpletest.66.patch no longer applies.
Comment #68
sunSimple diff context conflicts, clean merge.
Comment #69
sun68: table.simpletest.68.patch queued for re-testing.
Comment #70
sun68: table.simpletest.68.patch queued for re-testing.
Comment #71
moshe weitzman CreditAttribution: moshe weitzman commentedThis blocks some key theme DX issues. Up priority.
Comment #72
sunMerged 8.x.
Comment #74
sun72: table.simpletest.72.patch queued for re-testing.
Comment #75
sunComment #76
Dries CreditAttribution: Dries commentedGood little clean-up to bring things more inline. Committed to 8.x.
Comment #77
sunSorry, follow-up: #2207341: "Re-run tests" form action broken