Skip to content

Commit 237e179

Browse files
committed
[bugfix] Fix editing of numbers with Firefox
1 parent 3513bd2 commit 237e179

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

src/components/common/EditableLabelDuration.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
v-format-ns-duration="value"></span>
66
<input v-show="g.edit === true"
77
v-model="g.value"
8-
title=""
98
v-on:blur="updateValue"
109
@keyup.enter="updateValue"
1110
size="5"

src/components/common/EditableLabelNumber.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</label>
1111
<input v-show="g.edit === true"
1212
v-model="g.value"
13+
v-on:focus="g.focused = true"
1314
v-on:blur="updateValue"
1415
@keyup.enter="updateValue"
1516
:title="title"
@@ -19,7 +20,7 @@
1920
type="number"
2021
ref="input"
2122
/>
22-
<a class="btn-edit" v-on:click="edit()" v-show="!g.edit"><font-awesome-icon icon="edit"/></a>
23+
<a class="btn-edit" v-on:click="edit" v-show="!g.edit"><font-awesome-icon icon="edit"/></a>
2324
</span>
2425
</template>
2526

@@ -35,17 +36,23 @@
3536
callback: Function
3637
},
3738
data: function () {
38-
return {g: {edit: false, value: 0}}
39+
return {g: {edit: false, value: 0, focused: false}}
3940
},
4041
methods: {
4142
updateValue: function () {
42-
this.g.edit = false;
43-
this.callback(this.g.value)
43+
if (this.g.edit && this.g.focused) {
44+
this.g.edit = false;
45+
this.callback(this.g.value)
46+
}
47+
// remembering the focus is necessary for Firefox, as it fires the onblur too early
48+
this.g.focused = false;
4449
},
4550
edit: function () {
4651
this.g.edit = true;
4752
this.g.value = this.value;
48-
this.$nextTick(() => this.$refs.input.focus())
53+
this.$nextTick(() => {
54+
this.$refs.input.focus();
55+
})
4956
}
5057
}
5158
}
@@ -55,6 +62,7 @@
5562
input {
5663
text-align: center;
5764
}
65+
5866
.btn-edit {
5967
margin-left: 0.3em;
6068
margin-right: 0.3em;

src/components/common/EditableLabelSelect.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
},
3535
methods: {
3636
updateValue: function () {
37-
this.g.edit = false;
38-
this.callback(this.g.value)
37+
if (this.g.edit) {
38+
this.g.edit = false;
39+
this.callback(this.g.value)
40+
}
3941
},
4042
switchToEdit: function () {
4143
this.g.edit = true;

src/components/common/EditableLabelText.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
},
3434
methods: {
3535
updateValue: function () {
36-
this.g.edit = false;
37-
this.callback(this.g.value)
36+
if (this.g.edit) {
37+
this.g.edit = false;
38+
this.callback(this.g.value)
39+
}
3840
},
3941
edit: function () {
4042
this.g.edit = true;
@@ -49,6 +51,7 @@
4951
input {
5052
text-align: center;
5153
}
54+
5255
.btn-edit {
5356
margin-left: 0.3em;
5457
margin-right: 0.3em;

0 commit comments

Comments
 (0)