Skip to content

Commit

Permalink
Fix bug: Can not change input after clearable.
Browse files Browse the repository at this point in the history
  • Loading branch information
kieuminhcanh committed May 9, 2024
1 parent e9a68a6 commit 25858ce
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions packages/vuetify/src/labs/VConfirm/VConfirm.tsx
Expand Up @@ -6,15 +6,7 @@ import { makeVariantProps } from '@/composables/variant'

// Utilities
import { computed, ref, toRef, watch } from 'vue'
import {
VBtn,
VList,
VListItem,
VListItemAction,
VListItemTitle,
VMenu,
VTextField,
} from '../allComponents'
import { VBtn, VList, VListItem, VListItemAction, VListItemTitle, VMenu, VTextField } from '../allComponents'
import { genericComponent, propsFactory, useRender } from '@/util'

export const makeVConfirmProps = propsFactory(
Expand All @@ -29,7 +21,7 @@ export const makeVConfirmProps = propsFactory(
...makeVariantProps(),
...makeThemeProps(),
},
'VConfirm',
'VConfirm'
)

export const VConfirm = genericComponent()({
Expand All @@ -42,21 +34,16 @@ export const VConfirm = genericComponent()({
const isActive = ref(false)

const { themeClasses } = provideTheme(props)
const { backgroundColorClasses, backgroundColorStyles } =
useBackgroundColor(toRef(props, 'color'))
const { backgroundColorClasses, backgroundColorStyles } = useBackgroundColor(toRef(props, 'color'))
const { locationStyles } = useLocation(props)
watch(isActive, value =>
value
? (input.value = typeof props.input === 'string' ? props.input : '')
: '',
)
watch(isActive, value => (value ? (input.value = typeof props.input === 'string' ? props.input : '') : ''))

const showInput = computed(() => props.input || props.input !== false)

function onSubmit () {
isActive.value = false
if (props.onSubmit) {
props.onSubmit(props.input ? input.value : undefined)
props.onSubmit(input.value)
}
}
function onCancel () {
Expand Down Expand Up @@ -92,9 +79,7 @@ export const VConfirm = genericComponent()({
minWidth="200"
label={ props.text }
{ ...props.inputProps }
onKeydown={ (e: KeyboardEvent) =>
e.key === 'Enter' && onSubmit()
}
onKeydown={ (e: KeyboardEvent) => e.key === 'Enter' && onSubmit() }
/>
)}
</VListItemTitle>
Expand Down Expand Up @@ -131,4 +116,4 @@ export const VConfirm = genericComponent()({
},
})

export type VConfirm = InstanceType<typeof VConfirm>;
export type VConfirm = InstanceType<typeof VConfirm>

0 comments on commit 25858ce

Please sign in to comment.