mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 16:36:13 +00:00
Toolbar number input (#2288)
* Listen for ‘input’ event when input type is number, otherwise listen for 'change' event. * Remove checks for options type in the event handlers.
This commit is contained in:
parent
21e08709cb
commit
d0ab59f9da
@ -7,8 +7,7 @@
|
||||
<input :id="uid"
|
||||
:type="options.type"
|
||||
:value="options.value"
|
||||
v-bind="options.attrs"
|
||||
@change="onChange"/>
|
||||
v-bind="options.attrs"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -31,15 +30,26 @@ export default {
|
||||
uid: `mct-input-id-${inputUniqueId}`
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
if (this.options.type === 'number') {
|
||||
this.$el.addEventListener('input', this.onInput);
|
||||
} else {
|
||||
this.$el.addEventListener('change', this.onChange);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.options.type === 'number') {
|
||||
this.$el.removeEventListener('input', this.onInput);
|
||||
} else {
|
||||
this.$el.removeEventListener('change', this.onChange);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onChange(event) {
|
||||
let value = event.target.value;
|
||||
|
||||
if (this.options.type === 'number') {
|
||||
value = event.target.valueAsNumber;
|
||||
}
|
||||
|
||||
this.$emit('change', value, this.options);
|
||||
this.$emit('change', event.target.value, this.options);
|
||||
},
|
||||
onInput(event) {
|
||||
this.$emit('change', event.target.valueAsNumber, this.options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user