Skip to content

Commit 9c2c700

Browse files
authored
fix(b-form-spinbutton): prevent double increment/decrement on mobile (fixes #4838) (#4842)
1 parent 6308a0f commit 9c2c700

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/form-spinbutton/form-spinbutton.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,6 @@ export const BFormSpinbutton = /*#__PURE__*/ Vue.extend({
366366
return
367367
}
368368
this.resetTimers()
369-
// Enable body mouseup event handler
370-
this.setMouseup(true)
371369
// Step the counter initially
372370
stepper(1)
373371
const threshold = this.computedThreshold
@@ -393,9 +391,10 @@ export const BFormSpinbutton = /*#__PURE__*/ Vue.extend({
393391
const { type, button } = evt || {}
394392
/* istanbul ignore if */
395393
if (type === 'mouseup' && button) {
396-
// we only care about left (main === 0) mouse button click
394+
// Ignore non left button (main === 0) mouse button click
397395
return
398396
}
397+
evt.preventDefault()
399398
this.resetTimers()
400399
this.setMouseup(false)
401400
// Trigger the change event
@@ -437,8 +436,10 @@ export const BFormSpinbutton = /*#__PURE__*/ Vue.extend({
437436
props: { scale: this.hasFocus ? 1.5 : 1.25 },
438437
attrs: { 'aria-hidden': 'true' }
439438
})
440-
const handler = evt => /* istanbul ignore next: until tests written */ {
439+
const handler = evt => {
441440
if (!isDisabled && !isReadonly) {
441+
evt.preventDefault()
442+
this.setMouseup(true)
442443
this.handleStepRepeat(evt, stepper)
443444
}
444445
}

0 commit comments

Comments
 (0)