question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failing to get initial value (Vue 3)

See original GitHub issue

This is my code. It works just fine, except when “restaurantId” has initial value, it doesn’t pre-select the option.

<restaurant-autocomplete v-model="filters.restaurantId" /> //Int

RestaurantAutocomplete.vue:

<template>
    <Multiselect
		    :delay="500"
		    :resolveOnLoad="!!$attrs.modelValue"
		    :options="async (q) => await autocomplete(q)" // [{value: Int, label: String}]
		    :searchable="true"
		    :filterResults="false"
		    :clearOnSearch="true"
		    :clearOnSelect="false"
		    placeholder="Restaurant"
		    :loading="loading"
		    @select="$emit('update:modelValue', $event)"/>
</template>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
adambereczcommented, Jan 5, 2021

But can you actually see Multiselect’s modelValue prop being set? I don’t think so because attribute inheritance works with non-prop attributes and :modelValue is a prop. So adding :modelValue="modelValue" to multiselect should solve the problem.

Btw generally if you have resolveOnLoad set to true and the resulting async option list contains an item which value equals to the initially set modelValue it will be selected once the async process finishes.

0reactions
tljafarcommented, Jul 19, 2021

I used :model-value="default_value" that’s worked for me in Vue 3

But can you actually see Multiselect’s modelValue prop being set? I don’t think so because attribute inheritance works with non-prop attributes and :modelValue is a prop. So adding :modelValue="modelValue" to multiselect should solve the problem.

Btw generally if you have resolveOnLoad set to true and the resulting async option list contains an item which value equals to the initially set modelValue it will be selected once the async process finishes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VueJS 3 - V-model not updating the initial data value
The v-model in not making the data reactive. I'm using vue@3.2.31 with Chromium browser version 88 on Linux and I have the following...
Read more >
Options: State - Vue.js
A function that returns the initial reactive state for the component instance. ... default : Specifies a default value for the prop when...
Read more >
Initial inline input value · Issue #3924 · vuejs/vue - GitHub
I took a look at the migration guide and found a confirmation it was not possible anymore, but I can't find any workaround....
Read more >
How to set a default value to input with a v-model via HTML?
As i said in the post, vue ignores default value when using v-model, is not possible change it dynamically too, we get this...
Read more >
Vue 3 Composition API: How to Omit `.value` in refs
In situations where we have a function that returns a ref , the Vue compiler would not be able to know that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found