Skip to content

Commit a0ea1e2

Browse files
author
sunxiaoyu
committed
fix input&&cascader data not change bug
1 parent b381d7d commit a0ea1e2

7 files changed

Lines changed: 19 additions & 9 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "santd",
3-
"version": "0.3.6",
3+
"version": "0.3.7",
44
"description": "san UI design",
55
"scripts": {
66
"start": "cross-env NODE_ENV=development node scripts/preview.js",

src/cascader/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
| popupStyle | 自定义浮层样式 | object | {} |
2424
| popupPlacement | 浮层预设位置:`bottomLeft` `bottomRight` `topLeft` `topRight` | string | bottomLeft |
2525
| popupVisible | 控制浮层显隐 | boolean | - |
26-
| showSearch | 在选择框中显示搜索框 | boolean | false |
26+
| showSearch | 在选择框中显示搜索框 | boolean \| object(详解如下) | false|
2727
| size | 输入框大小,可选 `large`<br> `default`<br> `small` | string | default |
2828
| style | 自定义样式 | cssProperty | - |
2929
| suffixIcon | 自定义的选择框后缀图标type | string | - |

src/cascader/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ export default san.defineComponent({
121121
sort = defaultSortFilteredOption,
122122
limit = defaultLimit
123123
} = showSearch;
124-
const flattenOptions = this.data.get('flattenOptions') || [];
124+
const options = this.data.get('options');
125+
const changeOnSelect = this.data.get('changeOnSelect') || false;
126+
const fieldNames = this.data.get('fieldNames') || {};
127+
128+
const flattenOptions = showSearch && flattenTree(options, {changeOnSelect, fieldNames}) || [];
125129
const inputValue = this.data.get('inputValue');
126130

127131
// Limit the filter if needed
@@ -190,8 +194,6 @@ export default san.defineComponent({
190194
loadData && this.data.set('loadData', loadData.bind(this.parentComponent));
191195

192196
const showSearch = this.data.get('showSearch');
193-
const options = this.data.get('options');
194-
showSearch && this.data.set('flattenOptions', flattenTree(options, this.data.get()));
195197
this.data.set('hasSlot', this.sourceSlots.noname && this.sourceSlots.noname.filter(item => !item.textExpr).length);
196198
this.data.set('hasDisplayRender', !!this.sourceSlots.named.displayRender);
197199

src/input/docs/autosize-textarea.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<s-textarea placeholder="Autosize height based on content lines" autosize="{{true}}"></s-textarea>
1111
</div>
1212
<div style="margin-bottom: 10px;">
13-
<s-textarea placeholder="Autosize height with minimum and maximum number of lines" autosize="{minRows: 2, maxRows: 6}"></s-textarea>
13+
<s-textarea placeholder="Autosize height with minimum and maximum number of lines" autosize="{{{minRows: 2, maxRows: 6}}}"></s-textarea>
1414
</div>
1515
</div>
1616
</template>

src/input/textarea.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export default san.defineComponent({
1616
},
1717
attached() {
1818
this.resizeTextarea();
19+
let value = this.data.get('value') || '';
20+
if (!value) {
21+
let defaultValue = this.data.get('defaultValue') || '';
22+
this.data.set('value', defaultValue);
23+
}
1924
},
2025
updated() {
2126
this.resizeTextarea();
@@ -44,7 +49,7 @@ export default san.defineComponent({
4449
this.nextTick(() => {
4550
this.resizeTextarea();
4651
});
47-
this.fire('inputChange', e.target.value);
52+
this.fire('change', e.target.value);
4853
this.dispatch('UI:form-item-interact', {fieldValue: e.target.value, type: 'change', e});
4954
},
5055
handleBlur(e) {
@@ -66,7 +71,7 @@ export default san.defineComponent({
6671
on-input="handleTextareaChange($event)"
6772
on-keydown="handleKeyDown($event)"
6873
on-blur="handleBlur($event)"
69-
value="{{value || defaultValue}}"
74+
value="{=value=}"
7075
></textarea>
7176
`
7277
});

src/upload/src/ajaxUploader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ export default san.defineComponent({
161161
}
162162
},
163163
handleChange(e) {
164-
const files = e.target.files;
164+
const files = Array.prototype.slice.call(e.target.files).filter(
165+
file => attrAccept(file, this.data.get('accept'))
166+
);
165167
this.uploadFiles(files, e);
166168
this.reset();
167169
},

src/upload/upload.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const uploadButtonTemplate = `
2121
style="{{showButton ? '' : 'display:none;'}}"
2222
>
2323
<s-upload
24+
accept="{{accept}}"
2425
showButton="{{showButton}}"
2526
prefixCls="${prefixCls}"
2627
listType="{{listType}}"

0 commit comments

Comments
 (0)