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

w-input :model-value does not seem to be bidirectionally reactive #165

Open
Ophitoxaemia opened this issue Jan 4, 2025 · 0 comments
Open

Comments

@Ophitoxaemia
Copy link

Ophitoxaemia commented Jan 4, 2025

Using this code, which sets model-value to the reactive prop firstName:
Screenshot from 2025-01-04 13-43-47

And referencing the documentation that says model-value "Gets updated on text input."
Screenshot from 2025-01-04 14-03-06

However, we can see in the app, the values marked by the red arrows on the left are different. If the reactivity was bidirectional, I would expect the {{ firstName }} in the template to track the value in the input field.

Further, we can see in the console.log that the event param str tracks the value, while firstName.value does not change.
waveapp

I can get my desired behavior by changing the definition of w-input to this:
Screenshot from 2025-01-04 13-54-20

and processing the event param like this:
Screenshot from 2025-01-04 13-54-35

However, this looks more like one way reactivity than two way to me. I would have expected the values marked by the red arrows on the left to be the same.

Original code:


<template>
<div v-if="props.pdata.table" id="app" class="d-block">
  <w-table
    :headers="props.pdata.table.headers"
    :items="props.pdata.table.items"
    :selectable-rows="1"
    :selected-rows="[1]"
    @row-select="props.pdata.selectionInfo = $event">
  </w-table>
  <div v-if="props.pdata.selectionInfo.item">
    <w-input @update:model-value="handleInput" :model-value="firstName">First Name</w-input> 
  </div>
  firstName should be here: {{ firstName }}
</div>
</template>

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

const props = defineProps({pdata: Object})

const firstName = ref("default")

const handleInput = (str) => {
  console.log("1--"+str+"<<<")
  console.log("2--"+firstName.value+"<<<")
  props.pdata.table.items[props.pdata.selectionInfo.item.id-1].firstName = firstName.value
}
</script>

package.json, snipped


  "devDependencies": {
    "@vitejs/plugin-vue": "^5.0.4",
    "electron": "^29.1.1",
    "electron-builder": "^24.13.3",
    "vite": "^5.1.5",
    "vite-plugin-electron": "^0.28.4",
    "vite-plugin-electron-renderer": "^0.14.5",
    "vue": "^3.4.21"
  },
  "dependencies": {
    "wave-ui": "^3.18.0"
  }

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

No branches or pull requests

1 participant