File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,13 +93,17 @@ const Label = (props) => {
9393 }
9494 } ) ;
9595
96+ const colFormLabel = size || colClasses . length ;
97+ const formLabel = ! ( check || colFormLabel ) ;
98+
9699 const classes = mapToCssModules ( classNames (
97100 className ,
98101 hidden ? 'visually-hidden' : false ,
99102 check ? 'form-check-label' : false ,
100103 size ? `col-form-label-${ size } ` : false ,
101104 colClasses ,
102- colClasses . length ? 'col-form-label' : 'form-label'
105+ colFormLabel ? 'col-form-label' : false ,
106+ formLabel ? 'form-label' : false
103107 ) , cssModule ) ;
104108
105109 return (
Original file line number Diff line number Diff line change @@ -27,12 +27,30 @@ describe('Label', () => {
2727 expect ( wrapper . hasClass ( 'col-form-label' ) ) . toBe ( true ) ;
2828 } ) ;
2929
30+ it ( 'should not render with "form-label" class when a col is provided' , ( ) => {
31+ const wrapper = shallow ( < Label sm = "6" > Yo!</ Label > ) ;
32+
33+ expect ( wrapper . hasClass ( "form-label" ) ) . toBe ( false ) ;
34+ } ) ;
35+
3036 it ( 'should render with "form-label" class when a col is not provided' , ( ) => {
3137 const wrapper = shallow ( < Label > Yo!</ Label > ) ;
3238
3339 expect ( wrapper . hasClass ( 'form-label' ) ) . toBe ( true ) ;
3440 } ) ;
3541
42+ it ( 'should render with "form-check-label" class when check is specified' , ( ) => {
43+ const wrapper = shallow ( < Label check > Yo!</ Label > ) ;
44+
45+ expect ( wrapper . hasClass ( "form-check-label" ) ) . toBe ( true ) ;
46+ } ) ;
47+
48+ it ( 'should not render with "form-label" class when check is specified' , ( ) => {
49+ const wrapper = shallow ( < Label check > Yo!</ Label > ) ;
50+
51+ expect ( wrapper . hasClass ( "form-label" ) ) . toBe ( false ) ;
52+ } ) ;
53+
3654 it ( 'should pass col size specific classes as Strings' , ( ) => {
3755 const wrapper = shallow ( < Label sm = "6" > Yo!</ Label > ) ;
3856
You can’t perform that action at this time.
0 commit comments