Skip to content

Commit

Permalink
fix(VTextField): placeholder show logic
Browse files Browse the repository at this point in the history
fixes #16519
fixes #16493
  • Loading branch information
johnleider committed Apr 10, 2023
1 parent 0709890 commit aab0a31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/vuetify/src/components/VFileInput/VFileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const VFileInput = genericComponent<VFileInputSlots>()({
multiple: Boolean,
hint: String,
persistentHint: Boolean,
placeholder: String,
showSize: {
type: [Boolean, Number] as PropType<boolean | 1000 | 1024>,
default: false,
Expand Down
12 changes: 11 additions & 1 deletion packages/vuetify/src/components/VTextField/VTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ export const VTextField = genericComponent<Omit<VInputSlots & VFieldSlots, 'defa
default: ({
props: { class: fieldClass, ...slotProps },
}) => {
const placeholder = computed(() => {
if (isDirty.value || (
!isFocused.value &&
props.label &&
!props.persistentPlaceholder
)) return ''

return props.placeholder
})

const inputNode = (
<input
ref={ inputRef }
Expand All @@ -224,7 +234,7 @@ export const VTextField = genericComponent<Omit<VInputSlots & VFieldSlots, 'defa
readonly={ isReadonly.value }
disabled={ isDisabled.value }
name={ props.name }
placeholder={ props.placeholder }
placeholder={ placeholder.value }
size={ 1 }
type={ props.type }
onFocus={ onFocus }
Expand Down

0 comments on commit aab0a31

Please sign in to comment.