Skip to content

Commit

Permalink
fix(VTimePicker): properly apply disabled props (#19964)
Browse files Browse the repository at this point in the history
Co-authored-by: John Leider <john@vuetifyjs.com>
  • Loading branch information
SonTT19 and johnleider committed Jun 11, 2024
1 parent 9e1cfbd commit 0ba4b78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/vuetify/src/labs/VTimePicker/VTimePickerClock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export const VTimePickerClock = genericComponent()({
}

function wheel (e: WheelEvent) {
if (!props.scrollable || props.disabled) return

e.preventDefault()

const delta = Math.sign(-e.deltaY || 1)
Expand Down Expand Up @@ -196,6 +198,8 @@ export const VTimePickerClock = genericComponent()({
}

function onMouseDown (e: MouseEvent | TouchEvent) {
if (props.disabled) return

e.preventDefault()

window.addEventListener('mousemove', onDragMove)
Expand Down Expand Up @@ -233,7 +237,7 @@ export const VTimePickerClock = genericComponent()({
]}
onMousedown={ onMouseDown }
onTouchstart={ onMouseDown }
onWheel={ (e: WheelEvent) => (props.scrollable && wheel(e)) }
onWheel={ wheel }
ref={ clockRef }
>
<div class="v-time-picker-clock__inner" ref={ innerClockRef }>
Expand Down
9 changes: 7 additions & 2 deletions packages/vuetify/src/labs/VTimePicker/VTimePickerControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const VTimePickerControls = genericComponent()({
<VBtn
active={ props.selecting === 1 }
color={ props.selecting === 1 ? props.color : undefined }
disabled={ props.disabled }
variant="tonal"
class={{
'v-time-picker-controls__time__btn': true,
Expand All @@ -85,6 +86,7 @@ export const VTimePickerControls = genericComponent()({
'v-time-picker-controls__time--with-ampm__btn': props.ampm,
'v-time-picker-controls__time--with-seconds__btn': props.useSeconds,
}}
disabled={ props.disabled }
variant="tonal"
text={ props.minute == null ? '--' : pad(props.minute) }
onClick={ () => emit('update:selecting', SelectingTimes.Minute) }
Expand Down Expand Up @@ -113,6 +115,7 @@ export const VTimePickerControls = genericComponent()({
'v-time-picker-controls__time__btn__active': props.selecting === 3,
'v-time-picker-controls__time--with-seconds__btn': props.useSeconds,
}}
disabled={ props.disabled }
text={ props.second == null ? '--' : pad(props.second) }
/>
)
Expand All @@ -133,8 +136,9 @@ export const VTimePickerControls = genericComponent()({
'v-time-picker-controls__ampm__btn': true,
'v-time-picker-controls__ampm__btn__active': props.period === 'am',
}}
disabled={ props.disabled }
text={ t('$vuetify.timePicker.am') }
variant="tonal"
variant={ props.disabled && props.period === 'am' ? 'elevated' : 'tonal' }
onClick={ () => props.period !== 'am' ? emit('update:period', 'am') : null }
/>

Expand All @@ -146,8 +150,9 @@ export const VTimePickerControls = genericComponent()({
'v-time-picker-controls__ampm__btn': true,
'v-time-picker-controls__ampm__btn__active': props.period === 'pm',
}}
disabled={ props.disabled }
text={ t('$vuetify.timePicker.pm') }
variant="tonal"
variant={ props.disabled && props.period === 'pm' ? 'elevated' : 'tonal' }
onClick={ () => props.period !== 'pm' ? emit('update:period', 'pm') : null }
/>
</div>
Expand Down

0 comments on commit 0ba4b78

Please sign in to comment.