When you apply "sortable" to a table (and the jquery.sorted library is loaded), it checks the last table to see if it doesn't contain a "td" element. However, this breaks a rowspan attribute, and causes it to not carry over as it parses to a tfoot rather than in the tbody.
Description
Details
Revisions and Commits
rMW MediaWiki | |||
rMWd6d563f07e6b Fixes T114604 | |||
rMW23210930c2c7 Fixes T114604 | |||
rMWc7770078c91f Fixes T114604 | |||
rMW796290bccb85 Fixes T114604 |
Related Objects
- Duplicates Merged Here
- T185975: Sortable tables and headers in the last row
Event Timeline
for ( i = len - 1; i >= 0; i-- ) { if ( $( $rows[ i ] ).children( 'td' ).length ) { break; } $tfoot.prepend( $( $rows[ i ] ) ); }
Changes to:
var tfootAdditions = [], rowspan, ii; for ( i = len - 1; i >= 0; i-- ) { if ( $( $rows[ i ] ).children( 'td' ).length ) { rowspanNum = $( $rows[ i ] ).children( 'td' ).attr( 'rowspan' ); if ( rowspan !== undefined ) { for ( ii = parseInt( rowspan ); ii < parseInt( rowspan ).length; ii++ ) { if ( tfootAdditions.indexOf( i + parseInt( rowspan ) ) !== -1 ) { tfootAdditions.splice( tfootAdditions.indexOf( i + parseInt( rowspan ) ) ); } } } continue; } tfootAdditions.push( i ); } for ( i = 0; i < tfootAdditions.length; i++ ) { $tfoot.prepend( $( $rows[ i ] ) ); }
Probably the hackiest way about the problem, but should resolve it :P
I think it's best that a developer takes a look, since the code is hacky and could be majorly improved. =]
@Cblair91: Thanks for taking a look at the code!
You are very welcome to use developer access to submit this as a Git branch directly into Gerrit.
If you don't want to set up Git/Gerrit, you can also use the Gerrit Patch Uploader. Thanks again!
Change 243521 had a related patch set uploaded (by Gerrit Patch Uploader):
Fixes T114604
Change 243522 had a related patch set uploaded (by Gerrit Patch Uploader):
Fixes T114604
-sigh- 3rd patch fixes all JSLint issues. Should do patches in future when not sleepy.
Change 243525 had a related patch set uploaded (by Gerrit Patch Uploader):
Fixes T114604
@Cblair91: Amending is covered in https://www.mediawiki.org/wiki/Gerrit/Tutorial#Amending_a_change_.28your_own_or_someone_else.27s.29 but no idea if Gerrit Patch Uploader also supports that. Sorry for any confusion I might have created. :-(
The README file for it says "To upload an update to an existing patch, copy the Change-Id line from that changeset, and add it to the bottom of your commit message.", so I'm pretty sure that's not true. But you don't need to use that thing anyway.
Sadly, I do not have access to GIT at this time. If somebody else could ammend the commit message, that would be great (Y)
Change 243525 had a related patch set uploaded (by TheDJ):
jquery.tablesorter: Support rowspan in tfoot
Where is this a problem right now ? theoretical, practical ? In wikicode, or in an extension ?
Also, will need a qunit testcase to verify that this will not regress at some point in the future.
Practical. A sortable table exists on one of my wikis, and is causing this issue currently. And yes, on a page using wikicode =]
Please give the EXACT piece of code so that the patch can be verified for correctness.
{| class="wikitable sortable" ! Month ! Content |- ! January | rowspan="2" | '''Added some stuff.''' |- ! February |}
The following code will change "February" into the table footer, rather than allowing the rowspan to carry into it.
This doesn't look correct. The point of the code is that any row containing a <td> disqualifies the row for inclusion into the tfoot.
Instead, it should probably keep track of the length of previously selected lines (n: 1 th, n-1: 1th + 1td) and then just fully bail tfoot emulation in such complex cases.
Accidental ticket closure. (due to import of repo and commitmessage actions being triggered ?)
Change 291342 had a related patch set uploaded (by MatthiasDD):
jquery.tablesorter: Rowspan td until footer row
Change 692110 had a related patch set uploaded (by BrandonXLF; author: BrandonXLF):
[mediawiki/core@master] jquery.tablesort: Keep track of rowspans when adding to tfoot
Hey @BrandonXLF could you share some wikitext markup for some tables that are fixed by your current patch? I'm having trouble replicating the issue and therefore testing it. Thanks in advance!
@Jdlrobson The markup
{| class="wikitable sortable" ! A1 ! A2 |- | B1 | B2 |- | D1 | rowspan="2" | D2 |- ! E1 |- ! F1 ! F2 |}
produces a table that is currently broken. The E1 row is moved into the footer, causing the D2 cell with a rowspan of 2 to no longer have its rowspan work.
With this fix the E1 row is not moved into the footer and the rowspan remains functional.
Just like any other cell with rowspan, it is split when the table is sorted.
Change 692110 merged by jenkins-bot:
[mediawiki/core@master] jquery.tablesorter: Keep track of rowspans when adding to tfoot
Change 243525 abandoned by Bartosz Dziewoński:
[mediawiki/core@master] jquery.tablesorter: Support rowspan in tfoot
Reason:
Alternative patch was merged.
Change 291342 abandoned by Bartosz Dziewoński:
[mediawiki/core@master] jquery.tablesorter: Rowspan td until footer row
Reason:
Alternative patch was merged.