dosubot[bot] commented on issue #31269: URL: https://github.com/apache/superset/issues/31269#issuecomment-2514195342
<!-- Greeting --> Hello @sampathkrsna829! I'm here to help you with any bugs, questions, or contributions. Let's work together to resolve this issue. <!-- Answer --> 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: 1. **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 <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx)</sup>. 2. **isEditMode Flag**: Verify that the `isEditMode` flag is correctly set to `false` when opening the modal for creating a new template. This flag determines whether the modal should load existing data or start fresh <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx)</sup>. 3. **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 <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx)</sup>. 4. **API Calls**: Ensure that the API calls are correctly differentiated between create and edit operations. The `createResource` function should be called for new templates, and `updateResource` for existing ones <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx)</sup>. 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. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
