Skip to content

Commit

Permalink
fix(InputMenu/SelectMenu): prevent unnecessary updates when modelValu…
Browse files Browse the repository at this point in the history
…e is unchanged (nuxt#2507)
  • Loading branch information
ersankarimi authored Nov 5, 2024
1 parent c71fdc8 commit 1a94b55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/runtime/components/forms/InputMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</template>

<script lang="ts">
import { ref, computed, toRef, watch, defineComponent } from 'vue'
import { ref, computed, toRef, watch, defineComponent, toRaw } from 'vue'
import type { PropType } from 'vue'
import {
Combobox as HCombobox,
Expand Down Expand Up @@ -436,6 +436,11 @@ export default defineComponent({
function onUpdate(value: any) {
query.value = ''
if (toRaw(props.modelValue) === toRaw(value)) {
return
}
emit('update:modelValue', value)
emit('change', value)
Expand Down
6 changes: 5 additions & 1 deletion src/runtime/components/forms/SelectMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
</template>

<script lang="ts">
import { ref, computed, toRef, watch, defineComponent } from 'vue'
import { ref, computed, toRef, watch, defineComponent, toRaw } from 'vue'
import type { PropType } from 'vue'
import {
Combobox as HCombobox,
Expand Down Expand Up @@ -551,6 +551,10 @@ export default defineComponent({
})
function onUpdate(value: any) {
if (toRaw(props.modelValue) === value) {
return
}
emit('update:modelValue', value)
emit('change', value)
emitFormChange()
Expand Down

0 comments on commit 1a94b55

Please sign in to comment.