Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VField/VInput): centerAffix doesn't work for underlined/plain #20064

Merged
merged 5 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/api-generator/src/locale/en/VField.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"props": {
"appendInnerIcon": "Creates a [v-icon](/api/v-icon/) component in the **append-inner** slot.",
"baseColor": "Sets the color of the input when it is not focused.",
"centerAffix": "Vertically align **appendInner**, **prependInner**, **clearIcon** and **label** in the center.",
"centerAffix": "Automatically apply **[singleLine](/api/v-field/#props-single-line)** under the hood, and vertically align **appendInner**, **prependInner**, **clearIcon**, **label** and **input field** in the center.",
"clearIcon": "The icon used when the **clearable** prop is set to true.",
"dirty": "Manually apply the dirty state styling.",
"disabled": "Removes the ability to click or target the input.",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-generator/src/locale/en/VInput.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"props": {
"backgroundColor": "Changes the background-color of the input.",
"centerAffix": "Vertically align **appendInner**, **prependInner**, **clearIcon** and **label** in the center.",
"centerAffix": "Vertically align **append** and **prepend** in the center.",
"direction": "Changes the direction of the input.",
"hideDetails": "Hides hint and validation errors. When set to `auto` messages will be rendered only if there's a message (hint, error message, counter value etc) to display.",
"hideSpinButtons": "Hides spin buttons on the input when type is set to `number`.",
Expand Down
8 changes: 6 additions & 2 deletions packages/vuetify/src/components/VField/VField.sass
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@

$root: &

@at-root #{selector.nest('.v-field.v-field--center-affix.v-field--variant-underlined, .v-field.v-field--center-affix.v-field--variant-plain', &)}
padding-top: unset
padding-bottom: unset

@at-root
@include tools.density('v-input', $input-density) using ($modifier)
@at-root #{selector.nest(&, $root)}
Expand Down Expand Up @@ -195,8 +199,8 @@
align-items: center
padding-top: 0

.v-field.v-field--variant-underlined,
.v-field.v-field--variant-plain
.v-field:not(.v-field--center-affix).v-field--variant-underlined,
.v-field:not(.v-field--center-affix).v-field--variant-plain
.v-field__append-inner,
.v-field__clearable,
.v-field__prepend-inner
Expand Down
12 changes: 5 additions & 7 deletions packages/vuetify/src/components/VField/VField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ export const makeVFieldProps = propsFactory({
default: '$clear',
},
active: Boolean,
centerAffix: {
type: Boolean,
default: undefined,
},
centerAffix: Boolean,
color: String,
baseColor: String,
dirty: Boolean,
Expand Down Expand Up @@ -136,8 +133,9 @@ export const VField = genericComponent<new <T>(
const { roundedClasses } = useRounded(props)
const { rtlClasses } = useRtl()

const isSingleLine = computed(() => props.singleLine || props.centerAffix)
const isActive = computed(() => props.dirty || props.active)
const hasLabel = computed(() => !props.singleLine && !!(props.label || slots.label))
const hasLabel = computed(() => !isSingleLine.value && !!(props.label || slots.label))

const uid = getUid()
const id = computed(() => props.id || `input-${uid}`)
Expand Down Expand Up @@ -242,7 +240,7 @@ export const VField = genericComponent<new <T>(
{
'v-field--active': isActive.value,
'v-field--appended': hasAppend,
'v-field--center-affix': props.centerAffix ?? !isPlainOrUnderlined.value,
'v-field--center-affix': props.centerAffix,
'v-field--disabled': props.disabled,
'v-field--dirty': props.dirty,
'v-field--error': props.error,
Expand All @@ -251,7 +249,7 @@ export const VField = genericComponent<new <T>(
'v-field--persistent-clear': props.persistentClear,
'v-field--prepended': hasPrepend,
'v-field--reverse': props.reverse,
'v-field--single-line': props.singleLine,
'v-field--single-line': isSingleLine.value,
'v-field--no-label': !label(),
[`v-field--variant-${props.variant}`]: true,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VInput/VInput.sass
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
input[type=number]
-moz-appearance: textfield

&--plain-underlined
&--plain-underlined:not(&--center-affix)

.v-input__prepend,
.v-input__append
Expand Down
5 changes: 1 addition & 4 deletions packages/vuetify/src/components/VInput/VInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ export interface VInputSlot {
export const makeVInputProps = propsFactory({
id: String,
appendIcon: IconValue,
centerAffix: {
type: Boolean,
default: true,
},
centerAffix: Boolean,
prependIcon: IconValue,
hideDetails: [Boolean, String] as PropType<boolean | 'auto'>,
hideSpinButtons: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VTextField/VTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export const VTextField = genericComponent<VTextFieldSlots>()({
style={ props.style }
{ ...rootAttrs }
{ ...inputProps }
centerAffix={ !isPlainOrUnderlined.value }
focused={ isFocused.value }
>
{{
Expand All @@ -202,6 +201,7 @@ export const VTextField = genericComponent<VTextFieldSlots>()({
dirty={ isDirty.value || props.dirty }
disabled={ isDisabled.value }
focused={ isFocused.value }
centerAffix={ props.centerAffix }
error={ isValid.value === false }
>
{{
Expand Down
10 changes: 5 additions & 5 deletions packages/vuetify/src/components/VTextarea/VTextarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Intersect from '@/directives/intersect'

// Utilities
import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'
import { callEvent, clamp, convertToUnit, filterInputAttrs, genericComponent, propsFactory, useRender } from '@/util'
import { callEvent, clamp, convertToUnit, filterInputAttrs, genericComponent, omit, propsFactory, useRender } from '@/util'

// Types
import type { PropType } from 'vue'
Expand Down Expand Up @@ -48,8 +48,8 @@ export const makeVTextareaProps = propsFactory({
suffix: String,
modelModifiers: Object as PropType<Record<string, boolean>>,

...makeVInputProps(),
...makeVFieldProps(),
...omit(makeVInputProps(), ['centerAffix']),
...omit(makeVFieldProps(), ['centerAffix']),
}, 'VTextarea')

type VTextareaSlots = Omit<VInputSlots & VFieldSlots, 'default'> & {
Expand Down Expand Up @@ -228,7 +228,7 @@ export const VTextarea = genericComponent<VTextareaSlots>()({
style={ props.style }
{ ...rootAttrs }
{ ...inputProps }
centerAffix={ rows.value === 1 && !isPlainOrUnderlined.value }
centerAffix={ false }
focused={ isFocused.value }
>
{{
Expand All @@ -253,7 +253,7 @@ export const VTextarea = genericComponent<VTextareaSlots>()({
{ ...fieldProps }
id={ id.value }
active={ isActive.value || isDirty.value }
centerAffix={ rows.value === 1 && !isPlainOrUnderlined.value }
centerAffix={ false }
dirty={ isDirty.value || props.dirty }
disabled={ isDisabled.value }
focused={ isFocused.value }
Expand Down
Loading