Jump to content

Bug: Table in fieldset corrupts when editing post


Recommended Posts

Just noticed this one.  Working on a character sheet template and have a table within a fieldset that's within another fieldset.  All looks OK on the saved post:

image.png.3b2ece9aa6ec0a6a51893d0b8c0e2946.png

 

but, when I go to edit the saved post, the first row of the Impacts table just collapses in on itself:
image.png.5e3916e9771dd5a2a5fc6a2f337da5b7.png

 

... and looking at the source, it has indeed taken that first row of the table and pulled it out to a top level <p> element, leaving the blank first row of the table in place.  Not sure if it's because the first row was marked as containing headers in the table dialog or not, that's my next thing to test.

        <hr>
        <div style="text-align:center;">
            <strong>IMPACTS</strong>
        </div>

        <div>
            <fieldset class="mw-fieldset">
                <legend class="mw-fieldset-legend"></legend>

                <div class="mw-fieldset-body">
                    <p>
                        <span style=""><strong>MISFORTUNES</strong></span><span style=""><strong>LASTING EFFECTS</strong></span><span style=""><strong>BURDENS</strong></span><span style=""><strong>CURRENT VEHICLE</strong></span>
                    </p>

                    <table border="1" cellpadding="0" cellspacing="0" style="width:100%;">
                        <tbody>
                            <tr>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                        </tbody>
                    </table>

                    <p>
                        &nbsp;
                    </p>
                </div>
            </fieldset>

            <p>

 

Link to comment
Share on other sites

Right, this is the source that's generated by the table editor (no manual source editing done) it fails because the <th> cells are embedded within the <tbody> tags instead of within a <thead> section.

<table align="center" border="1" cellpadding="1" cellspacing="1" style="width: 50%;">
	<tbody>
		<tr>
			<th>
				Test Header 1
			</th>
			<th>
				Test Header 2
			</th>
			<th>
				Test Header 3
			</th>
		</tr>
		<tr>
			<td>
				blah
			</td>
			<td>
				blah
			</td>
			<td>
				blah
			</td>
		</tr>
	</tbody>
</table>

 

what it should be generating is:

<table align="center" border="1" cellpadding="1" cellspacing="1" style="width: 50%;">
	<thead>
		<tr>
			<th>
				Test Header 1
			</th>
			<th>
				Test Header 2
			</th>
			<th>
				Test Header 3
			</th>
		</tr>
    </thead>
    <tbody>
		<tr>
			<td>
				blah
			</td>
			<td>
				blah
			</td>
			<td>
				blah
			</td>
		</tr>
	</tbody>
</table>

 

To replicate, create a table, then select the cells in the first row.  Ctrl-Right click to bring up the edit widget, select Cell > Cell Properties and set the cell type to 'Header'

image.png.c9d7843327ae5608664d816d2977ffc4.png

Link to comment
Share on other sites

  • 1 month later...

@Suzuki Stumpy After looking at this in some detail, the use of th tags doesn't offer much benefit other than implied styling. The most straightforward fix will be to remove the Headers and Cell Type dropdowns from the dialog boxes, so all cells are treated equally and don't cause one or the other sets of style rules to be violated. I don't see a huge downside since most of our table users are setting their own styles (as you did in your example) and aren't really using th for tabular data.

Link to comment
Share on other sites

×
×
  • Create New...