Opened 11 years ago

Last modified 9 years ago

#10682 confirmed Bug

Cannot set tablet headers back to None on table with one row

Reported by: nitesh Owned by:
Priority: Normal Milestone:
Component: General Version: 4.2
Keywords: Cc:

Description

When a table has one row, and Headers are set to Both. It is not possible to go back into table properties and set the headers back to None.

Steps to reproduce:

  1. Create a table with 1 row, 2 columns, Headers: Both
  2. Enter Table Properties and set Headers: None
  3. Click OK

Expected results:

  • Dialog exits and TH in the table are replaced with TD.

Actual results:

  • Dialog does not exit and there is a JavaScript error.

Here is one possible fix, applied to ckeditor/_source/plugins/table/dialogs/table.js (Note that this code segment is from version 3.6.5, although the bug is present in the latest version too):

// Move the row out of the THead and put it in the TBody:
thead = new CKEDITOR.dom.element( table.$.tHead );
tbody = table.getElementsByTag( 'tbody' ).getItem( 0 );

var previousFirstRow = tbody.getFirst();
while ( thead.getChildCount() > 0 )
{
    theRow = thead.getFirst();
    for ( i = 0; i < theRow.getChildCount() ; i++ )
    {
        var newCell = theRow.getChild( i );
        if ( newCell.type == CKEDITOR.NODE_ELEMENT )
        {
            newCell.renameNode( 'td' );
            newCell.removeAttribute( 'scope' );
        }
    }
    if ( previousFirstRow )
        theRow.insertBefore( previousFirstRow );
    else 
        theRow.appendTo( tbody );
}
thead.remove();

Attachments (2)

en.js (2.2 KB) - added by thom 9 years ago.
en.js - language label settings
table.js (21.6 KB) - added by thom 9 years ago.
table.js

Download all attachments as: .zip

Change History (4)

comment:1 Changed 11 years ago by Jakub Ś

Status: newconfirmed

Problem can be reproduced from CKEditor 3.0 in all browsers.

Message: Cannot read property '$' of null
Line: 189
URI: /ckeditor4/core/dom/node.js

Changed 9 years ago by thom

Attachment: en.js added

en.js - language label settings

Changed 9 years ago by thom

Attachment: table.js added

table.js

comment:2 Changed 9 years ago by thom

Added two files for the changes required to fix this issue and add a table footer option as well. The fix adds a tbody row if one is missing, adds the ability to set the last row as a tfoot group on the table, and fixes an issue where the table properties would not set the current value of header properly. (if there is no header row but the thead group exists, it shouldn't default to row)

Last edited 9 years ago by thom (previous) (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy