Page MenuHomePhabricator

Move sorttop rows from thead to second tbody
Open, Needs TriagePublic

Description

Currently, column header rows are moved from the <tbody> to the <thead> element. After sorting, rows with the "sorttop" class are moved to the bottom of the <thead>.

Problems: Mixing column header with "sorttop" rows makes it impossible to target just the column headers as a whole. The sticky gadget, sticky header template, and sticky table start/end template make the <thead> top-sticky. This helps keep headers in view while scrolling through long tables. Non-header "sorttop" rows should not be top-sticky, especially on smaller screens with limited real estate. Although you can make exactly one row top-sticky with the template, this isn't ideal when you have multiple header rows, and is structurally off if the row uses "rowspan". Making multiple rows individually top-sticky isn't practical since you now have overlapping sticky elements.

In addition, mixing "sorttop" and header rows makes it difficult/impossible to use CSS to select the last row of headers excluding the "sorttop" rows since level 4 selectors aren't fully supported.
Example: thead tr:not(.sorttop):has(+ tr.sorttop) {}

Solution: Move the "sorttop" rows to a second <tbody> under the <thead>, which HTML allows multiple <tbody>. I suggest adding a "sort" class to the one that should be sorted and adjusting the jquery.tablesorter to target it. This should help future-proof against the addition of a third <tbody> under it. It might be a good idea to also add a "sorttop" class to the <tbody> they are moved to.

Relates to T248936.

Event Timeline

I think a question we should answer, is: .. What is sorttop's purpose ? Is it to sort ? Or to provided fake headers (visual position without the semantic markup) ?
I've always considered it to be the latter.

Non-header "sorttop" rows should not be top-sticky

Is this really expected by the wider user base ? Do we have on wiki discussion about this where it came up more than once ?

Move the "sorttop" rows to a second <tbody> under the <thead>

I'm not against this, but we will have to check for css selectors and javascript that makes assumptions about how many bodies a table has, because I don't think we ever had multiple tbodies.

As I understand, the purpose of sorttop is to keep the row at the top after sorting, just as sortbottom keeps it at the bottom. I wouldn't think it is to provide fake headers since there is already a way to make headers. https://en.wikipedia.org/wiki/Help:Sortable_tables#Excluding_top_rows_from_sorting explains that it is to exclude the row(s) from sorting and keep them fixed at the top.

The only conversation I recall is a few years ago with Timeshifter where having it stick to the top during scrolling was undesirable, which I agree since there is limited real estate on small mobile screens in landscape view for both multiple sticky headers and sorttop rows, leaving little space for scrolling data potentially covering the data completely. See https://en.wikipedia.org/wiki/Template_talk:COVID-19_pandemic_data/styles.css/Archive_21#New_styles_feedback and some other sections on that page. It was discussed again at https://en.wikipedia.org/wiki/Template_talk:Sticky_header/Archive_1, a new version of the sticky headers.

I've never seen multiple tbodies on wikipedia.