Mayankaggarwal8055 commented on issue #3326:
URL: 
https://github.com/apache/apisix-dashboard/issues/3326#issuecomment-4068641971

   Hi @Baoyuantop, thanks for the clarification.
   
   I took a look at your points, and this is the approach I’m planning to 
follow:
   
   Unsaved changes detection
   I’ll first check whether methods.formState.isDirty works reliably after the 
current setValue inside the useEffect that syncs the config prop. If it 
correctly reflects only user-made changes, I’ll use that directly.
   
   If it turns out not to be reliable because of the sync logic, then I’ll fall 
back to comparing the current form value (for example getValues("config")) with 
the original config value that was synced into the form.
   
   Scope
   I’ll keep this behavior limited to add and edit modes only.
   In view mode, the drawer should continue closing normally without any 
confirmation.
   
   Closing flow
   When the user tries to close the drawer:
   
   if there are no unsaved changes, it will close normally
   
   if there are unsaved changes, a confirmation modal will be shown
   
   On confirm, the drawer will close and the form will reset.
   On cancel, the drawer will remain open.
   
   i18n
   I’ll add the required translation keys for all supported languages mentioned:
   en, zh, de, es, and tr.
   
   Implementation
   The main changes should be in 
src/components/form-slice/FormItemPlugins/PluginEditorDrawer.tsx. I’ll also 
check whether there’s already an existing pattern for unsaved-changes 
confirmation elsewhere in the dashboard and reuse it if appropriate.
   
   If this sounds good, I’ll move ahead with the implementation and open a PR.


-- 
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]

Reply via email to