File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 1- import { Directive , HostBinding , Input , OnInit } from "@angular/core" ;
1+ import {
2+ Directive ,
3+ HostBinding ,
4+ Input ,
5+ OnChanges
6+ } from "@angular/core" ;
27
38/**
49 * [See demo](../../?path=/story/components-grid--basic)
@@ -37,7 +42,7 @@ export class RowDirective {
3742@Directive ( {
3843 selector : "[ibmCol]"
3944} )
40- export class ColumnDirective implements OnInit {
45+ export class ColumnDirective implements OnChanges {
4146 @Input ( ) class = "" ;
4247
4348 @Input ( ) columnNumbers = { } ;
@@ -51,12 +56,14 @@ export class ColumnDirective implements OnInit {
5156 return this . _columnClasses . join ( " " ) ;
5257 }
5358
54- set ( classes : string ) {
59+ set columnClasses ( classes : string ) {
5560 this . _columnClasses = classes . split ( " " ) ;
5661 }
5762
58- ngOnInit ( ) {
63+ ngOnChanges ( ) {
5964 try {
65+ // Reset classes so we don't apply classes for the same breakpoint multiple times
66+ this . _columnClasses = [ ] ;
6067 const columnKeys = Object . keys ( this . columnNumbers ) ;
6168 if ( columnKeys . length <= 0 ) {
6269 this . _columnClasses . push ( "bx--col" ) ;
@@ -78,7 +85,7 @@ export class ColumnDirective implements OnInit {
7885 }
7986
8087 if ( this . class ) {
81- this . _columnClasses . push ( this . class ) ;
88+ this . _columnClasses = [ ... new Set ( [ ... this . _columnClasses , ... this . class . split ( " " ) ] ) ] ;
8289 }
8390 }
8491}
You can’t perform that action at this time.
0 commit comments