Skip to content

Commit 8b2593e

Browse files
authored
fix(Grid): fix the border style error when the griditems is not an integer multiple of columns (#3740)
1 parent fe712ba commit 8b2593e

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/grid-item/grid-item.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default class GridItem extends SuperComponent {
102102
// 获取应该加在gridWrap上的padding
103103
getPaddingStyle() {
104104
const { gutter } = this.parent.properties;
105-
if (gutter) return `padding-left:${gutter}rpx;padding-top:${gutter}rpx`;
105+
if (gutter) return `padding-bottom:${gutter}rpx;padding-right:${gutter}rpx`;
106106
return '';
107107
}
108108

@@ -114,7 +114,7 @@ export default class GridItem extends SuperComponent {
114114
if (!isObject(border)) border = {} as any;
115115
const { color = '#266FE8', width = 2, style = 'solid' } = border as any;
116116
if (gutter) return `border:${width}rpx ${style} ${color}`;
117-
return `border-top:${width}rpx ${style} ${color};border-left:${width}rpx ${style} ${color}`;
117+
return `border-bottom:${width}rpx ${style} ${color};border-right:${width}rpx ${style} ${color}`;
118118
}
119119

120120
onClick(e) {

src/grid/__test__/index.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ describe('grid', () => {
2626
comp.attach(document.createElement('parent-wrapper'));
2727

2828
const $content = comp.querySelector('#grid >>> .t-grid__content');
29-
expect($content.dom.style.marginLeft).toBe('-4px');
29+
expect($content.dom.style.marginRight).toBe('-4px');
3030

3131
comp.setData({ border: true });
32-
expect($content.dom.style.marginLeft).toBe('-2px');
32+
expect($content.dom.style.marginRight).toBe('-2px');
3333

3434
comp.setData({ border: {} });
35-
expect($content.dom.style.marginLeft).toBe('-2px');
35+
expect($content.dom.style.marginRight).toBe('-2px');
3636
});
3737

3838
it(':gutter', () => {
@@ -42,7 +42,7 @@ describe('grid', () => {
4242
comp.setData({ gutter: 0 });
4343

4444
const $content = comp.querySelector('#grid >>> .t-grid__content');
45-
expect($content.dom.style.marginLeft).toBe('-0px');
45+
expect($content.dom.style.marginRight).toBe('-0px');
4646
});
4747

4848
it(':event', async () => {

src/grid/grid.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ export default class Grid extends SuperComponent {
5555
const { gutter } = this.properties;
5656
let { border } = this.properties;
5757

58-
if (!border) return `margin-left:-${gutter}rpx; margin-top:-${gutter}rpx`;
58+
if (!border) return `margin-bottom:-${gutter}rpx; margin-right:-${gutter}rpx`;
5959
if (!isObject(border)) border = {} as any;
6060
const { width = 2 } = border as any;
61-
return `margin-left:-${width}rpx; margin-top:-${width}rpx`;
61+
return `margin-bottom:-${width}rpx; margin-right:-${width}rpx`;
6262
},
6363
};
6464
}

src/upload/__test__/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe('upload', () => {
152152
const $gridItem = comp.querySelector('#t-upload >>> .t-grid-item');
153153
// gutter = 16, 单位 rpx
154154
expect($gridContent.dom.getAttribute('style')).toEqual(
155-
`margin-left:-${comp.data.gutter}px; margin-top:-${comp.data.gutter}px`,
155+
`margin-bottom:-${comp.data.gutter}px; margin-right:-${comp.data.gutter}px`,
156156
);
157157

158158
// gridConfig: width、 height

0 commit comments

Comments
 (0)