🌐 AI搜索 & 代理 主页
Skip to content

Commit e102949

Browse files
committed
Update form-text.js
1 parent 3c543b0 commit e102949

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

src/mixins/form-text.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -164,34 +164,36 @@ export default {
164164
// Make sure to always clear the debounce when `updateValue()`
165165
// is called, even when the v-model hasn't changed
166166
this.clearDebounce()
167-
value = this.modifyValue(value)
168-
if (value !== this.vModelValue) {
169-
const doUpdate = () => {
167+
// Define the shared update logic in a method to be able to use
168+
// it for immediate and debounced value changes
169+
const doUpdate = () => {
170+
value = this.modifyValue(value)
171+
if (value !== this.vModelValue) {
170172
this.vModelValue = value
171173
this.$emit('update', value)
174+
} else if (this.hasFormatter) {
175+
// When the `vModelValue` hasn't changed but the actual input value
176+
// is out of sync, make sure to change it to the given one
177+
// Usually caused by browser autocomplete and how it triggers the
178+
// change or input event, or depending on the formatter function
179+
// https://github.com/bootstrap-vue/bootstrap-vue/issues/2657
180+
// https://github.com/bootstrap-vue/bootstrap-vue/issues/3498
181+
/* istanbul ignore next: hard to test */
182+
const $input = this.$refs.input
183+
/* istanbul ignore if: hard to test out of sync value */
184+
if ($input && value !== $input.value) {
185+
$input.value = value
186+
}
172187
}
173-
const debounce = this.computedDebounce
174-
// Only debounce the value update when a value greater than `0`
175-
// is set and we are not in lazy mode or this is a forced update
176-
if (debounce > 0 && !lazy && !force) {
177-
this.$_inputDebounceTimer = setTimeout(doUpdate, debounce)
178-
} else {
179-
// Immediately update the v-model
180-
doUpdate()
181-
}
182-
} else if (this.hasFormatter) {
183-
// When the `vModelValue` hasn't changed but the actual input value
184-
// is out of sync, make sure to change it to the given one
185-
// Usually caused by browser autocomplete and how it triggers the
186-
// change or input event, or depending on the formatter function
187-
// https://github.com/bootstrap-vue/bootstrap-vue/issues/2657
188-
// https://github.com/bootstrap-vue/bootstrap-vue/issues/3498
189-
/* istanbul ignore next: hard to test */
190-
const $input = this.$refs.input
191-
/* istanbul ignore if: hard to test out of sync value */
192-
if ($input && value !== $input.value) {
193-
$input.value = value
194-
}
188+
}
189+
// Only debounce the value update when a value greater than `0`
190+
// is set and we are not in lazy mode or this is a forced update
191+
const debounce = this.computedDebounce
192+
if (debounce > 0 && !lazy && !force) {
193+
this.$_inputDebounceTimer = setTimeout(doUpdate, debounce)
194+
} else {
195+
// Immediately update the v-model
196+
doUpdate()
195197
}
196198
},
197199
onInput(evt) {

0 commit comments

Comments
 (0)