Skip to content

Commit

Permalink
fix(VNumberInput): mobile friendly support (#19791)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwu9145 committed May 12, 2024
1 parent 1b56e4e commit 9520563
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/vuetify/src/labs/VNumberInput/VNumberInput.tsx
Expand Up @@ -19,7 +19,7 @@ import type { PropType } from 'vue'
import type { VTextFieldSlots } from '@/components/VTextField/VTextField'

type ControlSlot = {
click: () => void
click: (e: MouseEvent) => void
}

type VNumberInputSlots = Omit<VTextFieldSlots, 'default'> & {
Expand Down Expand Up @@ -108,11 +108,13 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
}
}

function onClickUp () {
function onClickUp (e: MouseEvent) {
e.stopPropagation()
toggleUpDown()
}

function onClickDown () {
function onClickDown (e: MouseEvent) {
e.stopPropagation()
toggleUpDown(false)
}

Expand Down Expand Up @@ -143,6 +145,10 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
model.value = v ? +(v) : undefined
}

function onControlMousedown (e: MouseEvent) {
e.stopPropagation()
}

useRender(() => {
const { modelValue: _, ...textFieldProps } = VTextField.filterProps(props)

Expand All @@ -162,6 +168,7 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
size="small"
tabindex="-1"
onClick={ onClickDown }
onMousedown={ onControlMousedown }
/>
) : (
<VDefaultsProvider
Expand Down Expand Up @@ -195,6 +202,7 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
name="increment-btn"
icon="$collapse"
onClick={ onClickUp }
onMousedown={ onControlMousedown }
size="small"
tabindex="-1"
/>
Expand Down Expand Up @@ -236,6 +244,7 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
tile
tabindex="-1"
onClick={ onClickUp }
onMousedown={ onControlMousedown }
/>
</div>
) : (!props.reverse
Expand All @@ -255,6 +264,7 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
tile
tabindex="-1"
onClick={ onClickDown }
onMousedown={ onControlMousedown }
/>

<VDivider vertical />
Expand Down Expand Up @@ -284,6 +294,7 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
]}
{ ...textFieldProps }
style={ props.style }
inputmode="decimal"
>
{{
...slots,
Expand Down

0 comments on commit 9520563

Please sign in to comment.