mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
fix: emit input event only if there is val to be deleted (#1038)
This commit is contained in:
@@ -819,7 +819,7 @@
|
|||||||
* @return {this.value}
|
* @return {this.value}
|
||||||
*/
|
*/
|
||||||
maybeDeleteValue() {
|
maybeDeleteValue() {
|
||||||
if (!this.searchEl.value.length && this.selectedValue && this.clearable) {
|
if (!this.searchEl.value.length && this.selectedValue && this.selectedValue.length && this.clearable) {
|
||||||
let value = null;
|
let value = null;
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
value = [...this.selectedValue.slice(0, this.selectedValue.length - 1)]
|
value = [...this.selectedValue.slice(0, this.selectedValue.length - 1)]
|
||||||
@@ -939,7 +939,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const defaults = {
|
const defaults = {
|
||||||
// delete
|
// backspace
|
||||||
8: e => this.maybeDeleteValue(),
|
8: e => this.maybeDeleteValue(),
|
||||||
// tab
|
// tab
|
||||||
9: e => this.onTab(),
|
9: e => this.onTab(),
|
||||||
|
|||||||
@@ -69,6 +69,16 @@ describe('Custom Keydown Handlers', () => {
|
|||||||
expect(spy).toHaveBeenCalledTimes(1);
|
expect(spy).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('will not emit input event if value has not changed with backspace', () => {
|
||||||
|
const Select = mountDefault();
|
||||||
|
Select.vm.$data._value = 'one';
|
||||||
|
Select.find({ ref: 'search' }).trigger('keydown.backspace');
|
||||||
|
expect(Select.emitted().input.length).toBe(1);
|
||||||
|
|
||||||
|
Select.find({ ref: 'search' }).trigger('keydown.backspace');
|
||||||
|
Select.find({ ref: 'search' }).trigger('keydown.backspace');
|
||||||
|
expect(Select.emitted().input.length).toBe(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user