From 4ac8aa4ad5048ecbd0d8a2e25d928953a4d1d646 Mon Sep 17 00:00:00 2001 From: SonTT19 <49301480+SonTT19@users.noreply.github.com> Date: Wed, 3 Jul 2024 04:13:55 +0700 Subject: [PATCH] fix(VNumberInput): fix inc/dec slots with split control variant (#20072) fixes #20056 --- .../src/labs/VNumberInput/VNumberInput.tsx | 154 +++++++++--------- 1 file changed, 73 insertions(+), 81 deletions(-) diff --git a/packages/vuetify/src/labs/VNumberInput/VNumberInput.tsx b/packages/vuetify/src/labs/VNumberInput/VNumberInput.tsx index c0acfe3f85f..23f6f241263 100644 --- a/packages/vuetify/src/labs/VNumberInput/VNumberInput.tsx +++ b/packages/vuetify/src/labs/VNumberInput/VNumberInput.tsx @@ -97,6 +97,11 @@ export const VNumberInput = genericComponent()({ return props.hideInput ? 'stacked' : props.controlVariant }) + const incrementIcon = computed(() => controlVariant.value === 'split' ? '$plus' : '$collapse') + const decrementIcon = computed(() => controlVariant.value === 'split' ? '$minus' : '$expand') + const controlNodeSize = computed(() => controlVariant.value === 'split' ? 'default' : 'small') + const controlNodeDefaultHeight = computed(() => controlVariant.value === 'stacked' ? 'auto' : '100%') + const incrementSlotProps = computed(() => ({ click: onClickUp })) const decrementSlotProps = computed(() => ({ click: onClickDown })) @@ -160,77 +165,80 @@ export const VNumberInput = genericComponent()({ useRender(() => { const { modelValue: _, ...textFieldProps } = VTextField.filterProps(props) + function incrementControlNode () { + return !slots.increment ? ( + + ) : ( + + { slots.increment(incrementSlotProps.value) } + + ) + } + + function decrementControlNode () { + return !slots.decrement ? ( + + ) : ( + + { slots.decrement(decrementSlotProps.value) } + + ) + } + function controlNode () { - const defaultHeight = controlVariant.value === 'stacked' ? 'auto' : '100%' return (
- { - !slots.decrement ? ( - - ) : ( - - { slots.decrement(decrementSlotProps.value) } - - ) - } + { decrementControlNode() } - { - !slots.increment ? ( - - ) : ( - - { slots.increment(incrementSlotProps.value) } - - ) - } + { incrementControlNode() }
) } @@ -245,15 +253,7 @@ export const VNumberInput = genericComponent()({
- + { incrementControlNode() }
) : (!props.reverse ? <>{ dividerNode() }{ controlNode() } @@ -265,15 +265,7 @@ export const VNumberInput = genericComponent()({ controlVariant.value === 'split' ? (
- + { decrementControlNode() }