Commit a78e6bab authored by Constance Okoghenun's avatar Constance Okoghenun Committed by Mike Greiling

Resolve "Placeholder when entering weight value"

parent 0c02254c
...@@ -114,7 +114,7 @@ export default { ...@@ -114,7 +114,7 @@ export default {
}, },
onSubmit(e) { onSubmit(e) {
const { value } = e.target; const { value } = e.target;
const validatedValue = Number(value); const validatedValue = parseInt(value, 10);
const isNewValue = validatedValue !== this.weight; const isNewValue = validatedValue !== this.weight;
this.hasValidInput = validatedValue >= 0 || value === ''; this.hasValidInput = validatedValue >= 0 || value === '';
...@@ -188,7 +188,9 @@ export default { ...@@ -188,7 +188,9 @@ export default {
ref="editableField" ref="editableField"
:value="weight" :value="weight"
class="form-control" class="form-control"
type="text" type="number"
min="0"
placeholder="Enter a number"
@blur="onSubmit" @blur="onSubmit"
@keydown.enter="onSubmit" @keydown.enter="onSubmit"
/> />
......
---
title: Added placeholder to weight input for issue sidebar
merge_request: 7346
author:
type: changed
...@@ -154,27 +154,6 @@ describe('Weight', function() { ...@@ -154,27 +154,6 @@ describe('Weight', function() {
}); });
}); });
it('triggers error on invalid string value', done => {
vm = mountComponent(Weight, {
...DEFAULT_PROPS,
editable: true,
});
vm.$el.querySelector('.js-weight-edit-link').click();
vm.$nextTick(() => {
const event = new CustomEvent('keydown');
event.keyCode = ENTER_KEY_CODE;
vm.$refs.editableField.click();
vm.$refs.editableField.value = 'potato';
vm.$refs.editableField.dispatchEvent(event);
expect(vm.hasValidInput).toBe(false);
done();
});
});
it('triggers error on invalid negative integer value', done => { it('triggers error on invalid negative integer value', done => {
vm = mountComponent(Weight, { vm = mountComponent(Weight, {
...DEFAULT_PROPS, ...DEFAULT_PROPS,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment