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

feat(VNumberInput): emit events when using controls #20366

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 Aug 20, 2024

Description

resolves #20342

Markup

<template>
  <v-app>
    <v-container>
      <v-number-input
        v-model="someValue"
        :loading="saving"
        clearable
        @blur="save"
        @click:clear="save"
        @click:control="save"
      />
      <pre class="mt-3">lastSavedValue: {{ lastSavedValue }}</pre>
    </v-container>
  </v-app>
</template>

<script setup>
  import { ref } from 'vue'

  const someValue = ref(0)
  const lastSavedValue = ref(0)
  const saving = ref(false)

  // simplified example - it would be debounced and guarded against race conditions in real life
  async function save() {
    const v = someValue.value
    if (v !== lastSavedValue.value) {
      saving.value = true
      await new Promise(r => setTimeout(r, 1000))
      lastSavedValue.value = v
      saving.value = false
    }
  }
</script>

@KaelWD KaelWD force-pushed the master branch 3 times, most recently from 4c970f9 to 6a3285f Compare September 3, 2024 18:11
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.

[Feature Request] [VNumberInput] Click event support for increment / decrement buttons
1 participant