Fix: Prevent API key modal from opening when clicking copy button#694
Open
rjnz2023 wants to merge 1 commit intoparcelvoy:mainfrom
Open
Fix: Prevent API key modal from opening when clicking copy button#694rjnz2023 wants to merge 1 commit intoparcelvoy:mainfrom
rjnz2023 wants to merge 1 commit intoparcelvoy:mainfrom
Conversation
### Problem
When users click the copy button to copy an API key in the API Keys settings page, the row's click event also fires, causing the edit/update modal to open unexpectedly. This creates a poor user experience where users have to close the modal every time they just want to copy a key.
### Solution
This PR fixes the issue by:
1. Adding `onClick={(e) => e.stopPropagation()}` to the cell-content div containing the API key value and copy button
2. Removing the unnecessary `handleCopy` function that was attempting to stop propagation
3. Simplifying the copy button to use a standard `onClick` handler instead of `onClickCapture`
4. Adding `type="button"` attribute for better semantic HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When users click the copy button to copy an API key in the API Keys settings page, the row's click event also fires, causing the edit/update modal to open unexpectedly. This creates a poor user experience where users have to close the modal every time they just want to copy a key.
Solution
This PR fixes the issue by:
onClick={(e) => e.stopPropagation()}to the cell-content div containing the API key value and copy buttonhandleCopyfunction that was attempting to stop propagationonClickhandler instead ofonClickCapturetype="button"attribute for better semantic HTMLChanges
apps/ui/src/views/settings/ApiKeys.tsxhandleCopyfunction (lines 33-37)stopPropagationto cell-content divBefore & After
Before: Clicking copy button → API key copied + modal opens
After: Clicking copy button → API key copied only (modal stays closed)