Skip to content

Commit

Permalink
Merge pull request #7484 from ckeditor/i/7483
Browse files Browse the repository at this point in the history
Fix (table): Table multi-cell selection should not be possible with the keystrokes when the TableSelection plugin is disabled. Closes #7483.
  • Loading branch information
jodator authored Jun 23, 2020
2 parents 9160e63 + e1d36b4 commit 2fee736
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/ckeditor5-table/src/tablekeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ export default class TableKeyboard extends Plugin {

const cellToSelect = tableMap.find( cellInfo => cellInfo.row == row && cellInfo.column == column ).cell;
const isForward = [ 'right', 'down' ].includes( direction );
const tableSelection = this.editor.plugins.get( 'TableSelection' );

if ( expandSelection ) {
const tableSelection = this.editor.plugins.get( 'TableSelection' );
if ( expandSelection && tableSelection.isEnabled ) {
const anchorCell = tableSelection.getAnchorCell() || focusCell;

tableSelection.setCellSelection( anchorCell, cellToSelect );
Expand Down
24 changes: 24 additions & 0 deletions packages/ckeditor5-table/tests/tablekeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,30 @@ describe( 'TableKeyboard', () => {
downArrowDomEvtDataStub.shiftKey = true;
} );

it( 'should move to the cell below if TableSelection plugin is disabled', () => {
editor.plugins.get( 'TableSelection' ).forceDisabled();

editor.editing.view.document.fire( 'keydown', leftArrowDomEvtDataStub );

assertEqualMarkup( getModelData( model ), modelTable( [
[ '00', '01', '02' ],
[ '10[]', '11', '12' ],
[ '20', '21', '22' ]
] ) );

editor.editing.view.document.fire( 'keydown', downArrowDomEvtDataStub );

assertEqualMarkup( getModelData( model ), modelTable( [
[ '00', '01', '02' ],
[ '10', '11', '12' ],
[ '[]20', '21', '22' ]
] ) );

expect( tableSelection.getAnchorCell() ).to.be.null;
expect( tableSelection.getFocusCell() ).to.be.null;
expect( selection.rangeCount ).to.equal( 1 );
} );

it( 'should expand the selection to the cell on the left', () => {
editor.editing.view.document.fire( 'keydown', leftArrowDomEvtDataStub );

Expand Down

0 comments on commit 2fee736

Please sign in to comment.