Skip to content

Commit fe48e9e

Browse files
TheSharpieOneeddywashere
authored andcommitted
fix(Col): account for 0 col properties (#378)
fixes: #374
1 parent be34d19 commit fe48e9e

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/Col.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ const Col = (props) => {
7878

7979
colClasses.push(mapToCssModules(classNames({
8080
[colClass]: columnProp.size || columnProp.size === '',
81-
[`push${colSizeInterfix}${columnProp.push}`]: columnProp.push,
82-
[`pull${colSizeInterfix}${columnProp.pull}`]: columnProp.pull,
83-
[`offset${colSizeInterfix}${columnProp.offset}`]: columnProp.offset
81+
[`push${colSizeInterfix}${columnProp.push}`]: columnProp.push || columnProp.push === 0,
82+
[`pull${colSizeInterfix}${columnProp.pull}`]: columnProp.pull || columnProp.pull === 0,
83+
[`offset${colSizeInterfix}${columnProp.offset}`]: columnProp.offset || columnProp.offset === 0
8484
})), cssModule);
8585
} else {
8686
colClass = getColumnSizeClass(isXs, colWidth, columnProp);

src/__tests__/Col.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ describe('Col', () => {
7070
expect(wrapper.hasClass('offset-sm-2')).toBe(true);
7171
});
7272

73+
it('should pass col size specific classes via Objects including 0', () => {
74+
const wrapper = shallow(<Col sm={{ size: 6, push: 0, pull: 0, offset: 0 }} />);
75+
76+
expect(wrapper.hasClass('col-sm-6')).toBe(true);
77+
expect(wrapper.hasClass('col')).toBe(true);
78+
expect(wrapper.hasClass('push-sm-0')).toBe(true);
79+
expect(wrapper.hasClass('pull-sm-0')).toBe(true);
80+
expect(wrapper.hasClass('offset-sm-0')).toBe(true);
81+
});
82+
7383
it('should pass col size when passing via object with size "auto"', () => {
7484
const wrapper = shallow(<Col
7585
sm={{ size: 'auto', push: 2, pull: 2, offset: 2 }}

0 commit comments

Comments
 (0)