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

fixes T1277897: fixed v-model binding in view 3 on checkbox and textbox #29169

Draft
wants to merge 2 commits into
base: 24_2_5
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions apps/vue/components/check-box-example.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<template>
<example-block title="v-model">
with value:
<br>
<dx-check-box v-model="checkBoxValue" />
<br>
<div>checkBoxValue: {{ checkBoxValue ? '🟢' : '🔴' }}</div>
<br>
-------------
<br>
with modelValue:
<br>
<input type="checkbox" v-model="checkBoxValue2" />
<br>
<div>checkBoxValue: {{ checkBoxValue2 ? '🟢' : '🔴' }}</div>
<br>
-------------
<br>
<br>
native:
<br>
<input v-model="inputValueNative" style="border: 1px solid gray;"/>
<div>text: {{ inputValueNative }}</div>
<br>
---------------
<br>
<br>
DX:
<br>
<dx-text-box v-model="inputValue" />
<div>text: {{ inputValue }}</div>
</example-block>
</template>

<script>
import { ref, watch } from 'vue';
import ExampleBlock from "./example-block";
import { DxCheckBox } from "devextreme-vue/check-box";
import { DxTextBox } from "devextreme-vue/text-box";
import { DxList, DxItem } from "devextreme-vue/list";

const checkBoxValue2 = ref(false);

watch(checkBoxValue2, (newValue) => console.log("checkBoxValue2 changed:", newValue));

export default {
components: {
ExampleBlock,
DxCheckBox,
DxTextBox,
DxList,
DxItem,
},
data() {
return {
checkBoxValue: false,
checkBoxValue2,
inputValue: 'inputValue',
inputValueNative: 'inputValueNative',
selectedItems: [],
};
},
methods: {
updateValue(event) {
console.log("updateValue:", event);
this.checkBoxValue = event.value;
}
}
};
</script>
9 changes: 7 additions & 2 deletions apps/vue/components/examples.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<text-box-example/>
<br/>
<validator-example/>
<br/>
<check-box-example/>
<br/>
</template>

<script>
Expand All @@ -46,7 +49,8 @@ import ScrollViewExample from "./scroll-view-example";
import TabPanelExample from "./tab-panel-example";
import TextBoxExample from "./text-box-example";
import ValidatorExample from "./validation-example";

import CheckBoxExample from "./check-box-example";

export default {
components: {
AccessingInstanceExample,
Expand All @@ -63,7 +67,8 @@ export default {
ScrollViewExample,
TabPanelExample,
TextBoxExample,
ValidatorExample
ValidatorExample,
CheckBoxExample
}
};
</script>
10 changes: 5 additions & 5 deletions packages/devextreme-vue/src/core/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ function setEmitOptionChangedFunc(
config.emitOptionChanged = (name: string, value: string) => {
const props = vueInstance.$props;
const vnode = vueInstance?.$?.vnode;
if (hasProp(vueInstance, name) && !isEqual(value, props[name]) && vueInstance.$emit) {
innerChanges[name] = toRaw(value);
const eventName = name === 'value' && hasVModelValue(vueInstance.$options, props, vnode)
? `update:${VMODEL_NAME}`
: `update:${name}`;
const eventName = name === 'value' && hasVModelValue(vueInstance.$options, props, vnode)
? `update:${VMODEL_NAME}`
: `update:${name}`;

if (hasProp(vueInstance, name) && !isEqual(value, props[eventName]) && vueInstance.$emit) {
innerChanges[name] = toRaw(value);
vueInstance.$emit(eventName, value);
}
};
Expand Down
Loading