-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Describe the bug
When BaseEditableHolder is used as a controlled component (i.e., its value is managed by the parent via v-model), it still updates its internal state (d_value). However, in a controlled setup, the component should only reflect the value provided by the parent and should not maintain an internal copy of the value.
This leads to issues such as:
- Ignoring validation rules: If the parent wants to reject a certain input,
BaseEditableHolderstill updates its local value, causing inconsistency. - Inconsistent two-way binding: Even if the parent does not update the value,
BaseEditableHolderappears to change, breaking the expected controlled behavior.
Suggested fix
Modify BaseEditableHolder so that it does not update its internal d_value when it is controlled by the parent. Instead, it should wait for the parent to update the value via v-model. Update the computed controlled attribute to watch for onUpdate:modelValue and ensure local updates only happen if the parent does not handle the modification.
Pull Request Link
No response
Reason for not contributing a PR
- Lack of time
- Unsure how to implement the fix/feature
- Difficulty understanding the codebase
- Other
Other Reason
I can submit a PR to fix this issue, but I am unsure of the impact this change might have on the overall library. Any guidance on potential side effects or areas that might be affected would be appreciated.
Reproducer
https://stackblitz.com/edit/primevue-4-vite-issue-template-virjsdqt?file=src%2FApp.vue
Environment
- Styled primevue
- Primevue 4.3.1
Vue version
3.2.45
PrimeVue version
4.3.1
Node version
No response
Browser(s)
No response
Steps to reproduce the behavior
- Open the StackBlitz example.
- Type more than 5 characters in the
InputTextfield. - Even though the parent enforces a 5-character limit,
InputTextupdates with extra characters, causing a desynchronization.
Expected behavior
If BaseEditableHolder is controlled (i.e., bound to a v-model in the parent), it should only reflect updates from the parent and should not maintain an internal value that updates automatically.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status