Skip to content

BaseEditableHolder should not update its internal value when controlled by the parent #7400

@YannisJustine

Description

@YannisJustine

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, BaseEditableHolder still updates its local value, causing inconsistency.
  • Inconsistent two-way binding: Even if the parent does not update the value, BaseEditableHolder appears 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

  1. Open the StackBlitz example.
  2. Type more than 5 characters in the InputText field.
  3. Even though the parent enforces a 5-character limit, InputText updates 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

No one assigned

    Labels

    Status: Pending ReviewIssue or pull request is being reviewed by Core Team

    Type

    No type

    Projects

    Status

    Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions