Skip to content

Commit

Permalink
feat(VTextField): only show placeholder on focus if label is set (#12635
Browse files Browse the repository at this point in the history
)

resolves #12499

Having both label and placeholder displayed can be a usability problem
as the placeholder looks very similar to typed text and could be
confused with user input at a glance
  • Loading branch information
KaelWD committed Nov 17, 2020
1 parent 9daeb16 commit ff500ba
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/vuetify/src/components/VTextField/VTextField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,10 @@ export default baseMixins.extend<options>().extend({
}
},
showLabel (): boolean {
return this.hasLabel && (!this.isSingle || (!this.isLabelActive && !this.placeholder))
return this.hasLabel && !(this.isSingle && this.labelValue)
},
labelValue (): boolean {
return !this.isSingle &&
Boolean(this.isFocused || this.isLabelActive || this.placeholder)
return this.isFocused || this.isLabelActive
},
},

Expand Down Expand Up @@ -388,7 +387,7 @@ export default baseMixins.extend<options>().extend({
autofocus: this.autofocus,
disabled: this.isDisabled,
id: this.computedId,
placeholder: this.placeholder,
placeholder: this.isFocused || !this.hasLabel ? this.placeholder : undefined,
readonly: this.isReadonly,
type: this.type,
},
Expand Down

0 comments on commit ff500ba

Please sign in to comment.