Skip to content

Commit a857c25

Browse files
committed
fix: ie trigger input when set placeholder
1 parent 6c05e25 commit a857c25

File tree

9 files changed

+39
-36
lines changed

9 files changed

+39
-36
lines changed

components/input/Input.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default {
3838
configProvider: { default: () => ConfigConsumerProps },
3939
},
4040
data() {
41-
const { value, defaultValue } = this.$props;
41+
const { value = '', defaultValue = '' } = this.$props;
4242
return {
4343
stateValue: !hasProp(this, 'value') ? defaultValue : value,
4444
};
@@ -85,18 +85,15 @@ export default {
8585
},
8686

8787
setValue(value, e) {
88-
// https://github.com/vueComponent/ant-design-vue/issues/92
89-
if (isIE && !isIE9 && this.stateValue === value) {
88+
if (this.stateValue === value) {
9089
return;
9190
}
9291
if (!hasProp(this, 'value')) {
9392
this.stateValue = value;
9493
} else {
9594
this.$forceUpdate();
9695
}
97-
if (!e.target.composing) {
98-
this.$emit('change.value', value);
99-
}
96+
this.$emit('change.value', value);
10097
let event = e;
10198
if (e.type === 'click' && this.$refs.input) {
10299
// click clear icon
@@ -124,8 +121,9 @@ export default {
124121
},
125122

126123
handleChange(e) {
127-
if (e.target.composing) return;
128-
this.setValue(e.target.value, e);
124+
const { value, composing } = e.target;
125+
if (composing || this.stateValue === value) return;
126+
this.setValue(value, e);
129127
},
130128

131129
renderClearIcon(prefixCls) {

components/input/TextArea.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
configProvider: { default: () => ConfigConsumerProps },
4343
},
4444
data() {
45-
const { value, defaultValue } = this.$props;
45+
const { value = '', defaultValue = '' } = this.$props;
4646
return {
4747
stateValue: fixControlledValue(!hasProp(this, 'value') ? defaultValue : value),
4848
nextFrameActionId: undefined,
@@ -116,16 +116,16 @@ export default {
116116
},
117117

118118
handleTextareaChange(e) {
119-
if (e.target.composing) return;
119+
const { value, composing } = e.target;
120+
if (composing || this.stateValue === value) return;
120121
if (!hasProp(this, 'value')) {
121-
this.stateValue = e.target.value;
122+
this.stateValue = value;
122123
this.resizeTextarea();
123124
} else {
124125
this.$forceUpdate();
125126
}
126-
if (!e.target.composing) {
127-
this.$emit('change.value', e.target.value);
128-
}
127+
128+
this.$emit('change.value', value);
129129
this.$emit('change', e);
130130
this.$emit('input', e);
131131
},

components/vc-calendar/src/date/DateInput.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,11 @@ const DateInput = {
8181
});
8282
this.__emit('clear', null);
8383
},
84-
onInputChange(event) {
85-
if (event.target.composing) return;
86-
const str = event.target.value;
87-
// https://github.com/vueComponent/ant-design-vue/issues/92
88-
if (isIE && !isIE9 && this.str === str) {
89-
return;
90-
}
84+
onInputChange(e) {
85+
const { value: str, composing } = e.target;
86+
const { str: oldStr = '' } = this;
87+
if (composing || oldStr === str) return;
88+
9189
const { disabledDate, format, selectedValue } = this.$props;
9290

9391
// 没有内容,合法并直接退出

components/vc-pagination/Options.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ export default {
3232
return `${opt.value} ${this.locale.items_per_page}`;
3333
},
3434
handleChange(e) {
35-
if (e.target.composing) return;
35+
const { value, composing } = e.target;
36+
if (composing || this.goInputText === value) return;
3637
this.setState({
37-
goInputText: e.target.value,
38+
goInputText: value,
3839
});
3940
},
4041
handleBlur() {

components/vc-select/Select.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,11 @@ const Select = {
302302
return value;
303303
},
304304

305-
onInputChange(event) {
306-
if (event.target.composing) return;
305+
onInputChange(e) {
306+
const { value: val, composing } = e.target;
307+
const { _inputValue = '' } = this;
308+
if (composing || _inputValue === val) return;
307309
const { tokenSeparators } = this.$props;
308-
const val = event.target.value;
309310
if (
310311
isMultipleOrTags(this.$props) &&
311312
tokenSeparators.length &&

components/vc-time-picker/Header.jsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,10 @@ const Header = {
6262
},
6363

6464
methods: {
65-
onInputChange(event) {
66-
if (event.target.composing) return;
67-
const str = event.target.value;
68-
// https://github.com/vueComponent/ant-design-vue/issues/92
69-
if (isIE && !isIE9 && this.str === str) {
70-
return;
71-
}
65+
onInputChange(e) {
66+
const { value: str, composing } = e.target;
67+
const { str: oldStr = '' } = this;
68+
if (composing || oldStr === str) return;
7269

7370
this.setState({
7471
str,

components/vc-tree-select/src/SearchInput.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,19 @@ const SearchInput = {
8686
this.inputRef.current.blur();
8787
}
8888
},
89+
handleInputChange(e) {
90+
const { value, composing } = e.target;
91+
const { searchValue = '' } = this;
92+
if (composing || searchValue === value) return;
93+
this.vcTreeSelect.onSearchInputChange(e);
94+
},
8995
},
9096

9197
render() {
9298
const { searchValue, prefixCls, disabled, renderPlaceholder, open, ariaId } = this.$props;
9399
const {
94-
vcTreeSelect: { onSearchInputChange, onSearchInputKeyDown },
100+
vcTreeSelect: { onSearchInputKeyDown },
101+
handleInputChange,
95102
} = this;
96103
return (
97104
<span class={`${prefixCls}-search__field__wrap`}>
@@ -108,7 +115,7 @@ const SearchInput = {
108115
},
109116
],
110117
}}
111-
onInput={onSearchInputChange}
118+
onInput={handleInputChange}
112119
onKeydown={onSearchInputKeyDown}
113120
value={searchValue}
114121
disabled={disabled}

components/vc-tree-select/src/Select.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,6 @@ const Select = {
790790
},
791791

792792
onSearchInputChange(event) {
793-
if (event.target.composing) return;
794793
const value = event.target.value;
795794
const { _treeNodes: treeNodes, _valueEntities: valueEntities } = this.$data;
796795
const { filterTreeNode, treeNodeFilterProp } = this.$props;

tests/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Vue from 'vue';
2+
import Base from '../components/base';
23
// Vue.config.silent = true
34

45
/* eslint-disable global-require */
@@ -25,6 +26,7 @@ const mockMath = Object.create(global.Math);
2526
mockMath.random = () => 0.5;
2627
global.Math = mockMath;
2728

29+
Vue.use(Base);
2830
Vue.component('transition-group', {
2931
props: ['tag'],
3032
render(createElement) {

0 commit comments

Comments
 (0)