Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

i/6631: The "Merge cells" split button should always be enabled #307

Merged
merged 1 commit into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/tableui.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,10 @@ export default class TableUI extends Plugin {
dropdownView.buttonView.set( {
label,
icon,
tooltip: true
tooltip: true,
isEnabled: true
} );

// The main part of the split button is bound to the "mergeTableCells" command only.
dropdownView.bind( 'isEnabled' ).to( editor.commands.get( mergeCommandName ) );

// The split button dropdown must be **always** enabled and ready to open no matter the state
// of the "mergeTableCells" command. You may not be able to merge multiple cells but you may want
// to split them. This is also about mobile devices where multi–cell selection will never work
// (that's why "Merge cell right", "Merge cell down", etc. are still there in the first place).
dropdownView.buttonView.arrowView.unbind( 'isEnabled' );
dropdownView.buttonView.arrowView.isEnabled = true;

// Merge selected table cells when the main part of the split button is clicked.
this.listenTo( dropdownView.buttonView, 'execute', () => {
editor.execute( mergeCommandName );
Expand Down
4 changes: 2 additions & 2 deletions tests/tableui.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ describe( 'TableUI', () => {
expect( dropdown.buttonView ).to.be.instanceOf( SplitButtonView );
} );

it( 'should bind #isEnabled to the "mergeTableCells" command', () => {
it( 'should have #isEnabled always true regardless of the "mergeTableCells" command state', () => {
command.isEnabled = false;
expect( dropdown.isEnabled ).to.be.false;
expect( dropdown.isEnabled ).to.be.true;

command.isEnabled = true;
expect( dropdown.isEnabled ).to.be.true;
Expand Down