ui
ui copied to clipboard
UTable #actions-data outdated when rows change
Environment
- Operating System: Darwin
- Node Version: v20.15.1
- Nuxt Version: 3.12.3
- CLI Version: 3.12.0
- Nitro Version: 2.9.7
- Package Manager: [email protected]
Version
v2.17.0
Reproduction
https://stackblitz.com/edit/github-hpn25g
Description
We recognized that the row data which is passed to "actions" does not reflect the state of the row data after the items array is replaced. This can happen when the whole list of items is refetched from a backend. It is relevant that the actions data is in sync with the rendered data since the actions themselves could also lead to other backend requests.
Repro:
- Load the page with the table (posts are fetched)
- Rename a single post via Rename action (modal input and confirm)
- Posts are rerendered, table properly reflects new name for one of the posts
- Reopen the Rename modal
- See there is still the former name present, there was also a log statement showing that old model data is passed
- Expectation would be that the table component always forwards the current data to the actions
I am aware that I have to "fake" the refetch mechanism since the used dummy API does not allow mutations on the server. In our real world scenario we have a real backend but the issue is still reproducible.
As a workaround we use a constant field of a model (e.g. "id") and grab the item from the refetched lists of models before we pass it to the modal.
Is this a real bug or are we doing something wrong here? If you could give me some hints where/how to start I could try to provide a PR with a fix.
Additional context
No response
Logs
No response