Skip to content

Commit 0d8e28c

Browse files
authored
fix(Upload): fixed component display error when changing draggable (#4030)
1 parent 231d65e commit 0d8e28c

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

packages/components/upload/upload.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,26 @@ export default class Upload extends SuperComponent {
132132
});
133133
}
134134

135+
/**
136+
* 重置拖拽布局状态
137+
*/
138+
resetDragLayout() {
139+
this.setData({
140+
dragBaseData: {},
141+
dragWrapStyle: '',
142+
dragLayout: false,
143+
});
144+
}
145+
135146
initDragLayout() {
136147
const { draggable, disabled } = this.properties;
137-
if (!draggable || disabled) return;
148+
const { customFiles } = this.data;
149+
150+
if (!draggable || disabled || customFiles.length === 0) {
151+
this.resetDragLayout();
152+
return;
153+
}
154+
138155
this.initDragList();
139156
this.initDragBaseData();
140157
}
@@ -170,15 +187,7 @@ export default class Upload extends SuperComponent {
170187
}
171188

172189
initDragBaseData() {
173-
const { classPrefix, rows, column, customFiles } = this.data;
174-
if (customFiles.length === 0) {
175-
this.setData({
176-
dragBaseData: {},
177-
dragWrapStyle: '',
178-
dragLayout: false,
179-
});
180-
return;
181-
}
190+
const { classPrefix, rows, column } = this.data;
182191
const query = this.createSelectorQuery();
183192
const selectorGridItem = `.${classPrefix} >>> .t-grid-item`;
184193
const selectorGrid = `.${classPrefix} >>> .t-grid`;

0 commit comments

Comments
 (0)