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 and Chart: DataTable mounting components twice, leading to problems with Chart #5743

Open
hammerlscs opened this issue May 15, 2024 · 0 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@hammerlscs
Copy link

hammerlscs commented May 15, 2024

Describe the bug

Using a Chart in a DataTable leads to the following error, if the array given to the DataTable as value contains exactly one element:

Failed to create chart: can't acquire context from the given item

And the following error with more than one element:

Uncaught (in promise) TypeError: existingChart.canvas is null

The problem is possibly related to the fact, that the Chart is mounted twice in quick succession.
The beforeUnmount of the Chart is called before the initChart function in the mounted is finished. Therefore, this.chart is still null and not destroyed.
The second call to mounted fails, because this.chart is not null at this point and was also not destroyed by the beforeUnmounted call.

Reproducer

https://stackblitz.com/edit/vitejs-vite-dvqqne?file=src%2FApp.vue

PrimeVue version

3.52.0

Vue version

3.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

  1. Create a new DataTable
  2. Use a Chart in one of the columns of the DataTable

Example: https://stackblitz.com/edit/vitejs-vite-dvqqne?file=src%2FApp.vue

The DataTable is in App.vue, the Chart is in TestComponent.vue.
The Bar Chart in TestComponent.vue is a simplified version of: https://primevue.org/chart/#basic

Expected behavior

No errors.

@hammerlscs hammerlscs added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant