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

refactor: remove computed() #21157

Merged
merged 4 commits into from
Mar 25, 2025
Merged

Conversation

KaelWD
Copy link
Member

@KaelWD KaelWD commented Mar 25, 2025

#21114

A lot of the time in VBtn is just computed() and computed.get() for pretty simple string values, can we speed it up by replacing computed with getters instead of creating a separate component?

Markup:

<template>
  <v-app>
    <v-container>
      <button @click="show = 'btn'">btn</button>
      <button @click="show = 'icon'">icon-btn</button>
      <button @click="show = false">hide</button>

      <v-btn v-for="i in 1000" v-if="show === 'btn'" icon="$vuetify" variant="flat" />
      <v-icon-btn v-for="i in 1000" v-if="show === 'icon'" icon="$vuetify" />
    </v-container>
  </v-app>
</template>

<script setup>
  import { computed, ref, watch } from 'vue'

  const show = ref(false)
</script>

@johnleider
Copy link
Member

johnleider commented Mar 25, 2025

Speed is one of many reasons for a new component. VBtn is tied to routing, groups, extra slots and defaults providers. It's also missing features like active-variant (we've talked about), tracking it's own active state internally and is super ugly to work with when using just icons. It only looks okay within components like VCardActions and VToolbar because they provide a default variant of 'text'.

I think moving VBtn icon's default size to 64px in v3 was ultimately the wrong decision. It lost it's separation from a Floating Action Button and now, in MD3, there is a specification for Icon buttons that's separate from regular buttons.

@johnleider johnleider force-pushed the refactor/remove-computed branch from 4912f9a to 794a4be Compare March 25, 2025 15:45
@johnleider
Copy link
Member

johnleider commented Mar 25, 2025

The playground causes a layout shift that adds quite a bit of time. can be removed by putting a <br> after the buttons.

@johnleider johnleider force-pushed the refactor/remove-computed branch from 1f538ed to 0635e02 Compare March 25, 2025 23:38
@johnleider johnleider marked this pull request as ready for review March 25, 2025 23:51
@johnleider johnleider merged commit 2ee47de into feat/v-icon-btn Mar 25, 2025
18 checks passed
@johnleider johnleider deleted the refactor/remove-computed branch March 25, 2025 23:51
@vuetifyjs vuetifyjs deleted a comment from ibriones-mmdc Mar 26, 2025
KaelWD added a commit that referenced this pull request Mar 27, 2025
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.

2 participants