Opened 7 years ago

Closed 7 years ago

#14743 closed Bug (duplicate)

getSelectedCells() function in table tools plugin returns incorrect cell when selection is in the header of a nested table

Reported by: goodaman Owned by:
Priority: Normal Milestone:
Component: General Version: 4.5.11
Keywords: Cc:


Steps to reproduce

(This can be reproduced in the CKEditor Full Featured Demo)

  1. Create a table.
  2. Create a table inside a non-header row of the the first table, with a header row.
  3. Place the cursor in a cell in the header row of the nested table.
  4. Perform one of the Row commands available in the Table Tools plugin (e.g. Insert Rows Before, Insert Rows After, or Delete Rows)

Expected result

The header row in the nested table should be acted upon according to the chosen operation.

Actual result

The selected action is performed on a row of the outer table.

Other details (browser, OS, CKEditor version, installed plugins)

Tested in IE 11, Chrome 51, Firefox 47
Windows 7
CKEditor 4.5.9
Table Tools Plugin

There is a bug in the getSelectedCells() function in the Table Tools plugin. Specifically, line 33:

var nearestCell = startNode.getAscendant( 'td', true ) || startNode.getAscendant( 'th', true );

When the selection is in a header row of a nested table, nearestCell will be a td element of the outer table, since that is the first operation performed in the "or" statement. I believe the line should instead be:

var nearestCell = startNode.getAscendant( { td:1, th:1 }, true );

This will correctly select the nearest td or th element in the nested table.

Line 50 should be changed in the same manner.

Change History (2)

comment:1 Changed 7 years ago by Jakub Ś

DUP of #11192

comment:2 Changed 7 years ago by Jakub Ś

Resolution: duplicate
Status: newclosed
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