Skip to content

Commit ac38f1f

Browse files
committed
fix: v0.15.11 - QDatetime/QColor not setting value when on mobile quasarframework#2047
1 parent fe97b34 commit ac38f1f

File tree

4 files changed

+46
-24
lines changed

4 files changed

+46
-24
lines changed

dev/components/form/datetime.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</small>
4040
</p>
4141
<q-datetime format="YYYY-MMMM-dddd Do Qo Q" v-model="model" type="date" align="right" />
42-
@input<q-datetime @change="value => log('@change', value)" @input="value => log('@input', value)" stack-label="Stack Label" v-model="model" type="date" clearable />
42+
@input<q-datetime @change="value => log('@change', value)" @input="value => log('@input', value)" stack-label="Stack Label" v-model="model" type="date" clearable @focus="log('Xfocus')" @blur="log('Xblur')" />
4343
@change<q-datetime :value="model" @change="value => { model = value; log('@change', value) }" @input="value => log('@input', value)" stack-label="Stack Label" type="date" clearable />
4444

4545
<q-datetime @change="value => log('@change', value)" @input="value => log('@input', value)" stack-label="Stack Label" v-model="model" type="date" clearable />

src/components/color/QColor.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,35 @@ export default {
116116
this.$emit('focus')
117117
},
118118
__onBlur (e) {
119-
if (this.$refs.popup && this.$refs.popup.showing) {
119+
if (!this.focused) {
120120
return
121121
}
122122

123-
this.__onHide()
124123
setTimeout(() => {
125124
const el = document.activeElement
126-
if (el !== document.body && !this.$refs.popup.$el.contains(el)) {
125+
if (
126+
!this.$refs.popup ||
127+
!this.$refs.popup.showing ||
128+
(el !== document.body && !this.$refs.popup.$el.contains(el))
129+
) {
130+
this.__onHide()
127131
this.hide()
128132
}
129133
}, 1)
130134
},
131-
__onHide (forceUpdate) {
132-
this.focused && this.$emit('blur')
133-
this.focused = false
135+
__onHide (forceUpdate, keepFocus) {
134136
if (forceUpdate || this.isPopover) {
135137
this.__update(forceUpdate)
136138
}
139+
if (!this.focused) {
140+
return
141+
}
142+
if (keepFocus) {
143+
this.$el.focus()
144+
return
145+
}
146+
this.$emit('blur')
147+
this.focused = false
137148
},
138149
__setModel (val, forceUpdate) {
139150
this.model = clone(val)
@@ -188,7 +199,7 @@ export default {
188199
},
189200
on: {
190201
click: () => {
191-
this.__onHide()
202+
this.__onHide(false, true)
192203
this.hide()
193204
}
194205
}
@@ -203,7 +214,7 @@ export default {
203214
},
204215
on: {
205216
click: () => {
206-
this.__onHide(true)
217+
this.__onHide(true, true)
207218
this.hide()
208219
}
209220
}
@@ -264,7 +275,7 @@ export default {
264275
},
265276
on: {
266277
show: this.__onFocus,
267-
hide: val => this.__onHide(true)
278+
hide: () => this.__onHide(true, true)
268279
}
269280
}, this.__getPicker(h))
270281
: h(QModal, {
@@ -277,7 +288,7 @@ export default {
277288
transition: this.transition
278289
},
279290
on: {
280-
dismiss: this.__onHide
291+
dismiss: () => this.__onHide(false, true)
281292
}
282293
}, this.__getPicker(h, true)),
283294

src/components/color/QColorPicker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export default {
207207
min: 0,
208208
max,
209209
readonly: !this.editable,
210-
tabindex: this.disable ? 0 : -1
210+
tabindex: this.editable ? 0 : -1
211211
},
212212
staticClass: 'full-width text-center q-no-input-spinner',
213213
domProps: {
@@ -232,10 +232,10 @@ export default {
232232
domProps: { value: this.model.hex },
233233
attrs: {
234234
readonly: !this.editable,
235-
tabindex: this.disable ? 0 : -1
235+
tabindex: this.editable ? 0 : -1
236236
},
237237
on: {
238-
input: this.__onHexChange,
238+
change: this.__onHexChange,
239239
blur: evt => this.editable && this.__onHexChange(evt, true)
240240
},
241241
staticClass: 'full-width text-center uppercase'

src/components/datetime/QDatetime.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,35 @@ export default {
129129
this.$emit('focus')
130130
},
131131
__onBlur (e) {
132-
if (this.$refs.popup && this.$refs.popup.showing) {
132+
if (!this.focused) {
133133
return
134134
}
135135

136-
this.__onHide()
137136
setTimeout(() => {
138137
const el = document.activeElement
139-
if (el !== document.body && !this.$refs.popup.$el.contains(el)) {
138+
if (
139+
!this.$refs.popup ||
140+
!this.$refs.popup.showing ||
141+
(el !== document.body && !this.$refs.popup.$el.contains(el))
142+
) {
143+
this.__onHide()
140144
this.hide()
141145
}
142146
}, 1)
143147
},
144-
__onHide (forceUpdate) {
145-
this.focused && this.$emit('blur')
146-
this.focused = false
148+
__onHide (forceUpdate, keepFocus) {
147149
if (forceUpdate || this.isPopover) {
148150
this.__update(forceUpdate)
149151
}
152+
if (!this.focused) {
153+
return
154+
}
155+
if (keepFocus) {
156+
this.$el.focus()
157+
return
158+
}
159+
this.$emit('blur')
160+
this.focused = false
150161
},
151162
__setModel (val, forceUpdate) {
152163
this.model = clone(val)
@@ -220,7 +231,7 @@ export default {
220231
},
221232
on: {
222233
click: () => {
223-
this.__onHide()
234+
this.__onHide(false, true)
224235
this.hide()
225236
this.__resetView()
226237
}
@@ -237,7 +248,7 @@ export default {
237248
},
238249
on: {
239250
click: () => {
240-
this.__onHide(true)
251+
this.__onHide(true, true)
241252
this.hide()
242253
this.__resetView()
243254
}
@@ -299,7 +310,7 @@ export default {
299310
},
300311
on: {
301312
show: this.__onFocus,
302-
hide: val => this.__onHide(true)
313+
hide: () => this.__onHide(true, true)
303314
}
304315
}, this.__getPicker(h))
305316
: h(QModal, {
@@ -312,7 +323,7 @@ export default {
312323
transition: this.transition
313324
},
314325
on: {
315-
dismiss: this.__onHide
326+
dismiss: () => this.__onHide(false, true)
316327
}
317328
}, this.__getPicker(h, true)),
318329

0 commit comments

Comments
 (0)