- Issue created by @jrglasgow
- πΊπΈUnited States jrglasgow Idaho
In looking at this I noticed a few things where the table row is getting processed...
foreach ($rows as $row) { if ($skip_first) { $skip_first = FALSE; continue; } $counter = 0; $tbodyTags = $xpath->query('//tbody//td|//th', $row); foreach ($tbodyTags as $tag) { if ($tag->nodeName === 'th') { $tag->setAttribute('scope', 'row'); } else { $data_label = $table_headers[$counter]; $tag->setAttribute('data-label', $data_label); } } }
in the foreach loop internal to the row the
$counter
variable is never incremented.I also noticed that the xpath query
$tbodyTags = $xpath->query('//tbody//td|//th', $row);
returns a list of 25 items... so it was looping through not only the items in the current row, but it was also looping through all of the cells in the table for each row.I modified this to instead just grab the
$row->childNodes</a> of the current row and this resolved the issue... the same section of code work if you have this instead <code> foreach ($rows as $row) { if ($skip_first) { $skip_first = FALSE; continue; } $counter = 0; foreach ($row->childNodes AS $tag) { switch ($tag->nodeName) { case 'th': $tag->setAttribute('scope', 'row'); case 'td': $data_label = $table_headers[$counter]; $tag->setAttribute('data-label', $data_label); $counter++; break; default: error_log($tag->nodeName); } } }
- Status changed to Needs review
over 1 year ago 4:43pm 31 July 2023 - @jrglasgow opened merge request.
- πΊπΈUnited States jrglasgow Idaho
found a couple of small issues with my patch
- First commit to issue fork.
-
smustgrave β
committed 27796978 on 2.0.x authored by
jrglasgow β
Issue #3378273: Stacked tables in Mobile has wrong headers
-
smustgrave β
committed 27796978 on 2.0.x authored by
jrglasgow β
- Status changed to Fixed
over 1 year ago 7:39pm 14 August 2023 - πΊπΈUnited States smustgrave
Confirmed the issue and that your MR 62 fixed it thanks!
Automatically closed - issue fixed for 2 weeks with no activity.