fix cancel on edit
Description
fix #2568
Implemented confirmation prompt when canceling comment edit.
- Created reusable
ConfirmModalcomponent with presets for different confirmation types. - Added confirmation modal logic to
comment.js eoggleEditfunction that checks for unsaved changes inlocalStorage. - Updated both
comment.jsandreply.jsto use the new reusable component. - Added
storageKeyPrefixtocomment-edit.jsto properly track form changes
Screenshots
https://github.com/user-attachments/assets/6c2ceda3-10e7-4dc1-9608-bc8029538f51
Additional Context
The implementation follows the exact same pattern used in reply.js to maintain consistency.
the confirmation logic is handled at the parent component level comment.js
This implementation DOES NOT fix the multi-tab problem highlighted by @adlai, a broader refactor of the editing system would be needed, which goes beyond the scope of this issue.
Checklist
Are your changes backward compatible? Please answer below: Yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below: 7/10
For frontend changes: Tested on mobile, light and dark mode? Please answer below: NaN
Did you introduce any new environment variables? If so, call them out explicitly here: No
Did you use AI for this? If so, how much did it assist you? I used AI to analyze the existing codebase and find interested files
[!NOTE] Cursor Bugbot is generating a summary for commit c4b2bd637618ddf40491e985d6f156c69a958d68. Configure here.
Thank you for the shout-out; and was my own limited human bafflement by the nightmare of modern client-side HTML5 codebases helpful in any way, given that you also had an AI tool review the entire codebase?
Thanks for your feedback! I removed the DeleteConfirm component from confirm-modal.js as it was unused and the first .trim() check in comment.js as suggested by @Soxasora - now any change (including whitespace) will trigger the confirmation