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

Handlebars Template Reverts to Default on Dataset Change #30704

Open
3 tasks done
dkrat7 opened this issue Oct 24, 2024 · 1 comment
Open
3 tasks done

Handlebars Template Reverts to Default on Dataset Change #30704

dkrat7 opened this issue Oct 24, 2024 · 1 comment

Comments

@dkrat7
Copy link
Contributor

dkrat7 commented Oct 24, 2024

Bug description

When editing a Handlebars chart, if you modify the dataset and save, the Handlebars template will revert to its default state. If you are unaware of this behavior and save the chart, your custom template will be lost.

  1. Open a Handlebars chart.
  2. Edit the dataset and save the changes.
  3. Observe that the Handlebars template field has been reset to the default, and your custom code has been replaced.

Screenshots/recordings

output.mp4

Superset version

master / latest-dev

Python version

I don't know

Node version

I don't know

Browser

Firefox

Additional context

This is not a new bug. I noticed it first in 4.0.0

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Copy link

dosubot bot commented Oct 24, 2024

Hey @dkrat7, I'm here to help you with any bugs, questions, or contributions you have for Superset. Let's tackle this issue together!

The issue you're experiencing, where the Handlebars template reverts to its default state upon changing the dataset, is likely related to how the HandlebarsViewer component handles state changes. The useMemo hook in this component triggers a recompile of the template whenever the templateSource or data changes, which could lead to the template resetting if not managed properly [1].

To address this, you might need to ensure that the custom template state is preserved across dataset changes. This could involve modifying the logic that handles state updates to prevent overwriting the custom template with the default one. You may want to look into how the state is managed and updated when a dataset change occurs, possibly by implementing a mechanism to save and restore the custom template state.

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant