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

Commit e89ad60

Browse files
authored
Merge pull request #522 from ckeditor/t/ckeditor5-font/51
Fix: `ColorGrid` should set the `#isOn` property value of new `ColorTiles`. See ckeditor/ckeditor5-font#51.
2 parents 5980905 + 5f2601e commit e89ad60

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/colorgrid/colorgridview.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ export default class ColorGridView extends View {
9090
}
9191
} );
9292

93+
this.items.on( 'add', ( evt, colorTile ) => {
94+
colorTile.isOn = colorTile.color === this.selectedColor;
95+
} );
96+
9397
colorDefinitions.forEach( item => {
9498
const colorTile = new ColorTileView();
9599

tests/colorgrid/colorgridview.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,23 @@ describe( 'ColorGridView', () => {
106106
expect( view.items.get( 2 ).isOn ).to.be.false;
107107
} );
108108

109+
it( 'should determine #isOn value when a ColorTileView is added', () => {
110+
view.selectedColor = 'gold';
111+
112+
const tile = new ColorTileView();
113+
tile.set( {
114+
color: 'gold',
115+
label: 'Gold',
116+
options: {
117+
hasBorder: false
118+
}
119+
} );
120+
121+
view.items.add( tile );
122+
123+
expect( view.items.get( 3 ).isOn ).to.be.true;
124+
} );
125+
109126
describe( 'add colors from definition as child items', () => {
110127
it( 'has proper number of elements', () => {
111128
expect( view.items.length ).to.equal( 3 );

0 commit comments

Comments
 (0)