Bug description
Under settings when we try to add a new CSS template, The system adds it. But in the same session we try to create a new CSS template, The previous Template opens up & the modal shows up the data of the earlier created CSS. A quick look up on the network tab shows that the calls is being taken up as an edit and throws an error.
Attaching the screengrab for reference.
P.S : The second time the edit is clicked the previous CSS is being pre populated.
Screenshots/recordings
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Safari
Additional context
No response
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.
Comment From: dosubot[bot]
Hello @sampathkrsna829! I'm here to help you with any bugs, questions, or contributions. Let's work together to resolve this issue.
The issue you're experiencing with the CSS template modal in Superset seems to be related to how the state is managed when creating a new template after just having created one. The modal might not be resetting its state properly, causing it to prepopulate with the previous template's data.
Here are a few areas to investigate and potentially address the issue:
-
State Initialization: Ensure that the state is correctly reset when opening the modal for a new template creation. The
useEffect
hook should initialize the state with empty fields when not in edit mode [1]. -
isEditMode Flag: Verify that the
isEditMode
flag is correctly set tofalse
when opening the modal for creating a new template. This flag determines whether the modal should load existing data or start fresh [1]. -
Modal Visibility: Check the logic controlling the modal's visibility and state reset. The
isHidden
state should be managed to ensure the modal resets its content when closed and reopened [1]. -
API Calls: Ensure that the API calls are correctly differentiated between create and edit operations. The
createResource
function should be called for new templates, andupdateResource
for existing ones [1].
Reviewing these areas in the code might help identify why the modal is not resetting as expected. Adjusting the state management logic should resolve the issue of the modal prepopulating with the previous template's data.
To continue talking to Dosu, mention @dosu.
Comment From: sahiladit
Can you assign it to me?
Comment From: rusackas
We don't usually do the "asignee" thing on our general Issues on the repo, but in this case, it's all yours @sahiladit! Thanks in advance.
Comment From: rusackas
This is indeed still an issue today. Refreshing clears the state of the page and lets you create a new template, for what it's worth. We're still open to PRs, this seems like a (hopefully) simple fix that nobody has had time for :)
Comment From: suraj-mandal
I would like to take a look at this issue, if no one is taking @rusackas
Comment From: SohamDas00
Hey I can solve this issue since no one has resolved this issue please assign me this issue @rusackas