Skip to content

Conversation

J-Sek
Copy link
Contributor

@J-Sek J-Sek commented Jun 12, 2025

Description

Another take on the reserved space for clear icon.

  • aims to keep fade-in/out on hover/focus
  • verify RTL
  • verify on VSelect with chips

Note1: I am not sure if I like the text shift in the textarea

Note2: we could just drop CSS in favor of JS transition - here is a minor improvement on top of #20474. It would only need (1) detection for media (hover: none) and (2) approval for the behavior change

fixes #20375
closes #20474
closes #20534

Markup:

<template>
  <v-container max-width="1000">
    <v-switch v-model="appendIcon" label="append icon" hide-details />
    <v-divider class="mb-6" />
    <v-row>
      <v-col cols="12" md="4">
        <v-text-field v-model="msg" :append-inner-icon="appendIcon ? 'mdi-cow' : undefined" clearable />
        <v-text-field v-model="msg" :append-inner-icon="appendIcon ? 'mdi-cow' : undefined" clearable persistent-clear />
        <v-text-field v-model="msg" :append-inner-icon="appendIcon ? 'mdi-cow' : undefined" />
      </v-col>
      <v-col cols="12" md="4">
        <v-number-input v-model="num" :append-inner-icon="appendIcon ? 'mdi-cow' : undefined" :precision="10" clearable />
        <v-number-input v-model="num" :append-inner-icon="appendIcon ? 'mdi-cow' : undefined" :precision="10" clearable persistent-clear />
        <v-number-input v-model="num" :append-inner-icon="appendIcon ? 'mdi-cow' : undefined" :precision="10" />
      </v-col>
      <v-col cols="12" md="4">
        <v-textarea v-model="msg" rows="2" auto-grow :append-inner-icon="appendIcon ? 'mdi-cow' : undefined" clearable />
        <v-textarea v-model="msg" rows="2" auto-grow :append-inner-icon="appendIcon ? 'mdi-cow' : undefined" clearable persistent-clear />
        <v-textarea v-model="msg" rows="2" auto-grow :append-inner-icon="appendIcon ? 'mdi-cow' : undefined" />
      </v-col>
    </v-row>
  </v-container>
</template>

<script setup>
  import { ref } from 'vue'
  const num = ref(111111111111.000000001)
  const msg = ref('tax the rich / tax the rich / tax the rich / tax the rich / tax the rich / tax')
  const appendIcon = ref(false)
</script>

@J-Sek J-Sek self-assigned this Jun 12, 2025
@J-Sek J-Sek requested a review from johnleider June 12, 2025 20:16
@johnleider johnleider requested review from Copilot June 12, 2025 21:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the VField component to stop reserving space for the clear icon and instead animate its width on hover or focus.

  • Removes hasClear from the hasAppend calculation in VField.tsx
  • Introduces max-width transitions and transform-based positioning for the clear icon in VField.sass

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/vuetify/src/components/VField/VField.tsx Stop treating clear button as an appended icon placeholder
packages/vuetify/src/components/VField/VField.sass Add max-width transitions and transform logic for clear icon
Comments suppressed due to low confidence (1)

packages/vuetify/src/components/VField/VField.tsx:224

  • [nitpick] The name hasAppend is now specific to the append icon and no longer covers the clear button. Renaming it to something like hasAppendIcon would make its purpose clearer.
const hasAppend = !!(slots['append-inner'] || props.appendInnerIcon)

transition-property: opacity, transform, max-width, margin
display: flex
justify-content: end
transform: translateX(calc(-0.5 * var(--v-field-padding-end) - #{$field-clearable-margin}))
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of translateX here won’t auto-flip in RTL mode, causing the clear icon to animate in the wrong direction. Consider using a logical property or adjusting the transform based on the dir attribute to preserve correct behavior in RTL layouts.

Suggested change
transform: translateX(calc(-0.5 * var(--v-field-padding-end) - #{$field-clearable-margin}))
transform: translateX(calc((#{settings.$dir == 'rtl' ? 0.5 : -0.5}) * var(--v-field-padding-end) - #{$field-clearable-margin}))

Copilot uses AI. Check for mistakes.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@J-Sek J-Sek added T: enhancement Functionality that enhances existing features S: maybe Functionality that we are considering labels Jul 29, 2025
@KaelWD KaelWD force-pushed the dev branch 2 times, most recently from 6331ca7 to 564ccc8 Compare September 10, 2025 13:29
@J-Sek J-Sek force-pushed the dev branch 3 times, most recently from a7fa817 to 2e2cddb Compare October 8, 2025 15:22
@J-Sek J-Sek added this to the v4.0.0 (Revisionist) milestone Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: VField S: maybe Functionality that we are considering T: enhancement Functionality that enhances existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant