8
0
Просмотр исходного кода

Merge branch 'master' into t/ckeditor5/1151

Piotrek Koszuliński 6 лет назад
Родитель
Сommit
3f41331414

+ 4 - 0
packages/ckeditor5-ui/src/colorgrid/colorgridview.js

@@ -90,6 +90,10 @@ export default class ColorGridView extends View {
 			}
 		} );
 
+		this.items.on( 'add', ( evt, colorTile ) => {
+			colorTile.isOn = colorTile.color === this.selectedColor;
+		} );
+
 		colorDefinitions.forEach( item => {
 			const colorTile = new ColorTileView();
 

+ 17 - 0
packages/ckeditor5-ui/tests/colorgrid/colorgridview.js

@@ -106,6 +106,23 @@ describe( 'ColorGridView', () => {
 			expect( view.items.get( 2 ).isOn ).to.be.false;
 		} );
 
+		it( 'should determine #isOn value when a ColorTileView is added', () => {
+			view.selectedColor = 'gold';
+
+			const tile = new ColorTileView();
+			tile.set( {
+				color: 'gold',
+				label: 'Gold',
+				options: {
+					hasBorder: false
+				}
+			} );
+
+			view.items.add( tile );
+
+			expect( view.items.get( 3 ).isOn ).to.be.true;
+		} );
+
 		describe( 'add colors from definition as child items', () => {
 			it( 'has proper number of elements', () => {
 				expect( view.items.length ).to.equal( 3 );