Item8647: TablePlugin generates empty tfoot, even when there are footer rows

Priority: Urgent
Current State: Closed
Released In: 1.1.4
Target Release: patch
Applies To: Extension
Component: TablePlugin
Branches:
Reported By: CrawfordCurrie
Waiting For:
Last Change By: GeorgeClark
Render.pm tries to generate thead and tfoot for tables, based on the rows in a TML table. Thus
| *Head* |
| Body |
| *Toe* |
should generate
<table>
 <thead>...Head...</thead>
 <tbody>...Body...</tbody>
 <tfoot>...Toe...</tfoot>
</table>
but it doesn't, it generates
<table>
 <thead>...Head...</thead>
 <tbody>...Body...
  ...<strong>Toe</strong>...</tbody>
 <tfoot></tfoot>
</table>
This is a PITA for any client-side table handlers, as they have to recognise the empty tfoot and process it.

-- CrawfordCurrie - 02 Mar 2010

I just checked again on trunk and it's even worse. Now it generates the first two rows in the thead and the footer row in the tbody!

The fault is in the TablePlugin, and is urgent.

-- CrawfordCurrie - 13 Oct 2011

Possible unit test:

Index: FormattingTests.pm
===================================================================
--- FormattingTests.pm   (revision 12748)
+++ FormattingTests.pm   (working copy)
@@ -1115,4 +1115,36 @@
 #    );
 }
 
+# make sure thead, tbody, tfoot are generated correctly
+sub test_thead_tfoot {
+    my $this = shift;
+    my $tml = <<TML;
+| *Head* |
+| Body |
+| *Foot* |
+TML
+my $html = <<HTML;
+<nop><nop><nop>
+<table class="foswikiTable" rules="none" border="1">
+ <thead>
+  <tr class="foswikiTableOdd foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
+   <th class="foswikiTableCol0 foswikiFirstCol foswikiLastCol">Head</th>
+  </tr>
+ </thead>
+ <tbody>
+  <tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
+   <td class="foswikiTableCol0 foswikiFirstCol foswikiLastCol">Body</td>
+  </tr>
+ </tbody>
+ <tfoot>
+  <tr class="foswikiTableOdd foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
+   <th class="foswikiTableCol0 foswikiFirstCol foswikiLastCol foswikiLast">Foot</td>
+  </th>
+ </tfoot>
+</table>
+HTML
+    $this->do_test($html, $tml);
+
+}
+
 1;

-- CrawfordCurrie - 13 Oct 2011

According to http://www.w3schools.com/tags/tag_tfoot.asp - Note: <tfoot> must appear before <tbody> within a table, so that a browser can render the foot before receiving all the rows of data.

We do not have any tests that cover tables with the TablePlugin disabled. I've added some tests to the FormattingTests, and it appears that the core Render code doesn't support table footers. It emits the "footer" row as a body row with strong emphasis.

-- GeorgeClark - 13 Oct 2011

Committed a fix in the way the header and footer rows are counted. Needs further validation for unusual table layouts - (header/footer row that's embedded in the middle of the table).

Also not sure that the plugin is completely correct. It assumes that any bold cell is a th cell, and any row with all th cells is a header row. I suspect that:
  • Cells should be th only when part of a header - ie all cells are th in the row.
  • Rows that are embedded in the table and are all bold, are not really header or footer. I suspect this layout might break things.

-- GeorgeClark - 15 Oct 2011

Indeed, there were still issues. Added the following test cases
  • Bold cells when no header or footer is present should not be sortable
  • Bold cells after the header before the footer should not be sortable. If no header, the footer still has to have the sort links.

Modified the code to only emit the sort links when it is really the last header row or first footer row.

-- GeorgeClark - 15 Oct 2011

Marking this fixed in the ReleaseNotes01x01. But leaving the task waiting for Feedback. I'd like CDot to verify the interaction with the client side table handler he referred to in the original report.

-- GeorgeClark - 24 Oct 2011

Looks good.

-- CrawfordCurrie - 02 Nov 2011

 
Topic revision: r16 - 17 Dec 2011, GeorgeClark
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License