stacker.news icon indicating copy to clipboard operation
stacker.news copied to clipboard

fix cancel on edit

Open pory-gone opened this issue 3 months ago • 2 comments

Description

fix #2568

Implemented confirmation prompt when canceling comment edit.

  • Created reusable ConfirmModal component with presets for different confirmation types.
  • Added confirmation modal logic to comment.js eoggleEdit function that checks for unsaved changes in localStorage.
  • Updated both comment.js and reply.js to use the new reusable component.
  • Added storageKeyPrefix to comment-edit.js to 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.

pory-gone avatar Oct 01 '25 16:10 pory-gone

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?

adlai avatar Oct 02 '25 16:10 adlai

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

pory-gone avatar Oct 23 '25 17:10 pory-gone