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): floating label should respect paddings to avoid overflow #20736

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

J-Sek
Copy link
Contributor

@J-Sek J-Sek commented Nov 26, 2024

Description

fixes #20734

Markup:

<template>
  <v-form>
    <v-container max-width="600">
      <v-text-field
        density="compact"
        variant="solo"
        v-model="label"
      />
      <div class="d-flex ga-3 align-center">
        rounded:
        <v-chip-group filter color="primary" v-model="rounded">
          <v-chip value="sm" text="sm" />
          <v-chip value="lg" text="lg" />
          <v-chip value="xl" text="xl" />
          <v-chip :value="true" text="true" />
          <v-chip value="pill" text="pill" />
        </v-chip-group>
      </div>
      <v-row>
        <v-col cols="12" sm="6">
          <v-text-field :label="label" model-value="asd" prepend-icon="mdi-map-marker" :rounded="rounded" />
          <v-text-field :label="label" model-value="asd" prepend-inner-icon="mdi-map-marker" :rounded="rounded" />
          <v-text-field append-icon="mdi-map-marker" :label="label" model-value="asd" :rounded="rounded" />
          <v-text-field append-inner-icon="mdi-map-marker" :label="label" model-value="asd" :rounded="rounded" />
        </v-col>

        <v-col cols="12" sm="6">
          <v-text-field :label="label" model-value="asd" prepend-icon="mdi-map-marker" variant="solo" :rounded="rounded" />
          <v-text-field :label="label" model-value="asd" prepend-inner-icon="mdi-map-marker" variant="solo" :rounded="rounded" />
          <v-text-field append-icon="mdi-map-marker" :label="label" model-value="asd" variant="solo" :rounded="rounded" />
          <v-text-field append-inner-icon="mdi-map-marker" :label="label" model-value="asd" variant="solo" :rounded="rounded" />
        </v-col>

        <v-col cols="12" sm="6">
          <v-text-field :label="label" model-value="asd" prepend-icon="mdi-map-marker" variant="outlined" :rounded="rounded" />
          <v-text-field :label="label" model-value="asd" prepend-inner-icon="mdi-map-marker" variant="outlined" :rounded="rounded" />
          <v-text-field append-icon="mdi-map-marker" :label="label" model-value="asd" variant="outlined" :rounded="rounded" />
          <v-text-field append-inner-icon="mdi-map-marker" :label="label" model-value="asd" variant="outlined" :rounded="rounded" />
        </v-col>

        <v-col cols="12" sm="6">
          <v-text-field :label="label" model-value="asd" prepend-icon="mdi-map-marker" variant="outlined" :rounded="rounded" />
          <v-text-field :label="label" model-value="asd" prepend-inner-icon="mdi-map-marker" variant="outlined" :rounded="rounded" />
          <v-text-field append-icon="mdi-map-marker" :label="label" model-value="asd" variant="outlined" :rounded="rounded" />
          <v-text-field append-inner-icon="mdi-map-marker" :label="label" model-value="asd" variant="outlined" :rounded="rounded" />
        </v-col>
      </v-row>
    </v-container>
  </v-form>
</template>

<script setup>
  import { ref } from 'vue'
  const rounded = ref(undefined)
  const label = ref('test test test test test test test test test test test test test test')
</script>

@J-Sek
Copy link
Contributor Author

J-Sek commented Nov 26, 2024

Outlined version needs some additional treatment

  • avoid cutting short labels
  • show the missing part of outline
  • (existing issue) keep right borders rounded
screenshot

image

@KaelWD KaelWD marked this pull request as draft December 3, 2024 10:21
@J-Sek J-Sek marked this pull request as ready for review January 25, 2025 00:55
@J-Sek
Copy link
Contributor Author

J-Sek commented Jan 25, 2025

A small regression was introduced in recently merged #20349, so I decided to patch it as well.

As as side-note: I don't like that rule because floating label shifts too much. It would be nice to have a new --v-field-border-radius variable so we can calculate flex-basis and max-width from the exact rounding. example

@J-Sek J-Sek requested a review from johnleider January 25, 2025 01:16
Comment on lines +408 to +409
#{selector.append('[class^="rounded-"]', &)},
#{selector.append('[class*=" rounded-"]', &)}
Copy link
Member

Choose a reason for hiding this comment

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

I understand why this is needed but (I believe) this would the first code of its type in the framework. Would love to get thoughts from anyone else on the @vuetifyjs/core-team

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These 3 lines (with selector.append) are the exact copy from a few lines above. I wish I would not do it, but adding --v-field-border-radius feels like it would need to go to dev branch first and I want to patch regression, so it needs to go to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.7.4] Text-field Label Text Does Not Truncate Correctly When It Exceeds Width
2 participants