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

DataTable: Modifying value of expendedRow is not reflected #5372

Closed
bdh92123 opened this issue Mar 4, 2024 · 7 comments · Fixed by #5637 or DallinAllred/ezanalytics#11 · May be fixed by Thiritin/identity#87 or jennytoc/mfe-proj#2
Closed
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@bdh92123
Copy link
Contributor

bdh92123 commented Mar 4, 2024

Describe the bug

If only part of the data specified as expandedRows is modified externally, it will not be reflected.

The deep property seems to be false when watching expandedRows. It seems problematic that the entire value must be replaced to be reflected.

Reproducer

https://stackblitz.com/edit/ydc9nq?file=src%2FApp.vue

PrimeVue version

3.48.0

Vue version

3.x

Language

ALL

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

In reproducer, click "Expand black watch" button.

Expected behavior

Black watch row should be expanded.

@bdh92123 bdh92123 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 4, 2024
@TheZlodziej
Copy link

TheZlodziej commented Mar 16, 2024

I don't think it's primevue problem. Arrays used with vue's reactive system are hard to work with. Essentially, it cannot detect the change unless you reassign the value of the array (and array elements are not the value). For example, if you change the button's callback to this function

function expandBlackWatch() {
  expandedRows.value[1001] = true
  expandedRows.value = [...expandedRows.value]
}

it would work since vue can detect that the value of expandedRows has changed (to the copy of existing array with value at index 1001 changed).

@bdh92123
Copy link
Contributor Author

bdh92123 commented Mar 25, 2024

@TheZlodziej Why don't you consider using the 'deep' option when watching expandedRows? It is wasteful to always copy the entire array whenever only part of changes.

@TheZlodziej
Copy link

@bdh92123 I'm not sure what you mean. Can you provide some links so I can educate myself?

@bdh92123
Copy link
Contributor Author

bdh92123 commented Mar 26, 2024

@TheZlodziej In document, the 'deep' watcher can detect changes to array elements. However, prime data tables watch the expandedRows property without it, and as you mentioned, we should always change the entire value of the property and there is no reason for that.

@pollna
Copy link

pollna commented Apr 1, 2024

@bdh92123 thank you very much for pointing this out - I was confused and have been trying to fix programmatic row expansion for 2 hours straight, before I saw this issue. Otherwise it would take me way more time, I couldn't imagine it is a new DataTable bug 😔

@tugcekucukoglu
Copy link
Member

Thanks for the updates. It's a demo bug. The default value of expandedRows should be {}.

Thank you!

@tugcekucukoglu tugcekucukoglu added Component: Documentation Issue or pull request is related to Documentation and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 1, 2024
@bdh92123
Copy link
Contributor Author

bdh92123 commented Apr 1, 2024

Thanks for the updates. It's a demo bug. The default value of expandedRows should be {}.

Thank you!

@tugcekucukoglu The difference between {} and [] is whether or not the dataKey attribute is present. It has nothing to do with this issue and is by no means a demo bug. I don't know why you closed the issue without reading my post sincerely. This is an issue that simply requires adding the 'deep' option to true in the part that watches expandedRows of the DataTable.
It is in

bdh92123 added a commit to bdh92123/primevue that referenced this issue Apr 24, 2024
@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Component: Documentation Issue or pull request is related to Documentation labels Apr 24, 2024
@tugcekucukoglu tugcekucukoglu added this to the 3.52.0 milestone Apr 24, 2024
tugcekucukoglu added a commit that referenced this issue Apr 24, 2024
Fixed #5372: DataTable: Modifying value of expendedRow is n…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
4 participants