Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/autocomplete/src/autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@
},
watch: {
suggestionVisible(val) {
this.broadcast('ElAutocompleteSuggestions', 'visible', [val, this.$refs.input.$refs.input.offsetWidth]);
let $input = this.getInput();
if ($input) {
this.broadcast('ElAutocompleteSuggestions', 'visible', [val, $input.offsetWidth]);
}
}
},
methods: {
Expand Down Expand Up @@ -248,15 +251,19 @@
suggestion.scrollTop -= highlightItem.scrollHeight;
}
this.highlightedIndex = index;
this.$el.querySelector('.el-input__inner').setAttribute('aria-activedescendant', `${this.id}-item-${this.highlightedIndex}`);
let $input = this.getInput();
$input.setAttribute('aria-activedescendant', `${this.id}-item-${this.highlightedIndex}`);
},
getInput() {
return this.$refs.input.getInput();
}
},
mounted() {
this.debouncedGetData = debounce(this.debounce, this.getData);
this.$on('item-click', item => {
this.select(item);
});
let $input = this.$el.querySelector('.el-input__inner');
let $input = this.getInput();
$input.setAttribute('role', 'textbox');
$input.setAttribute('aria-autocomplete', 'list');
$input.setAttribute('aria-controls', 'id');
Expand Down
14 changes: 10 additions & 4 deletions packages/input/src/input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@

methods: {
focus() {
(this.$refs.input || this.$refs.textarea).focus();
this.getInput().focus();
},
blur() {
(this.$refs.input || this.$refs.textarea).blur();
this.getInput().blur();
},
getMigratingConfig() {
return {
Expand All @@ -245,7 +245,7 @@
}
},
select() {
(this.$refs.input || this.$refs.textarea).select();
this.getInput().select();
},
resizeTextarea() {
if (this.$isServer) return;
Expand Down Expand Up @@ -286,7 +286,10 @@

// set input's value, in case parent refuses the change
// see: https://github.com/ElemeFE/element/issues/12850
this.$nextTick(() => { this.$refs.input.value = this.value; });
this.$nextTick(() => {
let input = this.getInput();
input.value = this.value;
});
},
handleChange(event) {
this.$emit('change', event.target.value);
Expand Down Expand Up @@ -322,6 +325,9 @@
this.$emit('input', '');
this.$emit('change', '');
this.$emit('clear');
},
getInput() {
return this.$refs.input || this.$refs.textarea;
}
},

Expand Down