-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error which appear with columnDelete
command when table contained colspans
#653
Conversation
plugins/tabletools/plugin.js
Outdated
// Where to put the cursor after columns been deleted? | ||
// 1. Into next cell of the first row if any; | ||
// 2. Into previous cell of the first row if any; | ||
// 3. Into table's parent element; | ||
var cursorPosition = new CKEDITOR.dom.element( firstRowCells[ startColIndex ] || ( startColIndex ? firstRowCells[ startColIndex - 1 ] : table.$.parentNode ) ); | ||
var cursorPosition; | ||
if ( map[ 0 ].length - 1 > endColIndex && map[ 0 ][ endColIndex + 1 ].cellIndex !== -1 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm… I don't get the logic behind this condition. It seems to work, but I don't understand why :D Could elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First part of condition map[ 0 ].length - 1 > endColIndex
check if there was some columns on the right after deleted part.
map[ 0 ].length - 1
is the last index of possible column valueendColIndex
is last index of deleted column.
Second part of condition map[ 0 ][ endColIndex + 1 ].cellIndex !== -1
checks, if cell (endColIndex + 1
) located after deleted column, is still in table. Theoretically it should be always true, if first part is true ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed second part it seems to be confusing.
@@ -0,0 +1,74 @@ | |||
/* bender-tags: editor,unit */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests connected with tableselection
plugin should be inserted into tableselection/integrations
directory. It allows to easily find all issues related to integrations between tableselection
and other plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll prepare two sets of test with and without tableselection plugin to cover more cases.
@@ -0,0 +1,14 @@ | |||
@bender-tags: 4.7.2, bug, 577 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests connected with tableselection
plugin should be inserted into tableselection/integrations
directory. It allows to easily find all issues related to integrations between tableselection
and other plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's done. ;)
1. Open browser console. | ||
1. Select some cells somwhere under merged header. | ||
1. Selection should use `tableselection` plugin. | ||
1. Right click to open cntentxt menu. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix typos in test description.
this.doTest( 'table-1', 'columnDelete' ); | ||
}, | ||
|
||
'test remove 2 last columns by single row selection': function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add ticket references before every test connected with it.
// Where to put the cursor after columns been deleted? | ||
// 1. Into next cell of the first row if any; | ||
// 2. Into previous cell of the first row if any; | ||
// 3. Into table's parent element; | ||
var cursorPosition = new CKEDITOR.dom.element( firstRowCells[ startColIndex ] || ( startColIndex ? firstRowCells[ startColIndex - 1 ] : table.$.parentNode ) ); | ||
var cursorPosition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I wonder if it could be moved to tableselection
plugin using its internal customizeTableCommand
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally tabletools
doesn't depend on tableselection
so we cannot assume that tableselection
will be loaded.
d29de25
to
7e9cd3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix is not working properly
Case 1
- Open http://tests.ckeditor.dev:1030/tests/plugins/tableselection/manual/integrations/tabletools/columndeletionerror
- Select cells from two last columns.
- Open context menu and select Column → Delete Columns.
- Press Undo.
- Click into cell in the last column (selection should become collapsed).
- Open context menu and select Column → Delete Columns.
Expected:
Last column is deleted.
Actual:
Nothing happens.
Case 2
- Open http://tests.ckeditor.dev:1030/tests/plugins/tabletools/manual/columndeletionerror
- Select cells from two last columns (actually it's equivalent to select some rows).
- Click inside cell in last column to collapse selection.
- Open context menu and select Column → Delete columns.
Expected:
Last column is deleted.
Actual:
Nothing happens.
@Comandeer
Browser natively, after opening context menu, highlight clicked word. In this case it cause enlarging selection to next cell if we're at the end of cell. Do you think that I should prepare some custom solution to fix in CKEditor? |
There are already some workarounds for context menu in our |
plugins/tabletools/plugin.js
Outdated
} | ||
|
||
// Problem occures only on webkit in case of native selection (#577 | ||
if ( CKEDITOR.env.webkit && !selection.isFake && selection.getNative().type === 'Range' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the last part of the statement really needed? Probably it could be replaced with checking if range is non-collapsed.
plugins/tabletools/plugin.js
Outdated
return range.select(); | ||
} | ||
|
||
// Problem occures only on webkit in case of native selection (#577 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be nice to link also upstream issue here.
1. Select some cells somewhere under merged header. | ||
1. Selection should use native selection. | ||
1. Right click to open context menu. | ||
1. Select Column -> Delete Column. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's "Delete Columns", not "Column".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found one more issue with fix for Chrome.
- Put collapsed selection on the end of cell in column 4.
- Press right mouse button and select "Column"→"Delete Columns"
- Press "Undo" button
Expected result: selection is contained inside one cell.
Actual result: two cells are selected: the desired one and the first one from the next row.
@Comandeer mentioned behaviour seems to be not related to this bug.
Entire situation has happens because of using And task for it, if we decide to make fix for that ;) #846 |
…est and description to manual
…est case to manual tests.
What is the purpose of this pull request?
bug fix
Does your PR contain necessary tests?
yes
This PR contains
What changes did you make?
{}
to if statements.close #577