-
-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added stopPropagation to "copy text" buttons in backend #4019
Merged
Conversation
This file contains 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
@hirale any thoughts on this? |
@Caprico85 |
Thanks @Caprico85 That looks to be VERY helpful! |
fballiano
approved these changes
May 29, 2024
It's a good idea. |
hirale
approved these changes
May 29, 2024
fballiano
changed the title
Prevent other actions from running when clicking the copy text button
Added stopPropagation to "copy text" buttons in backend
May 29, 2024
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.
Description (*)
This PR adds
event.stopPropagation()
andevent.preventDefault()
to the new copyText() function.The copy function is a very nice feature, which we already added to several other locations. Now our editors wanted to be able to copy values from backend grids, like this:
Adding the copy button can be done using a renderer. But the copy button is clicked, the event propagates up the DOM and triggers the row click, which navigates to the details page.
This is not what we wanted. I think, clicking the copy button should just do the copying and not do anything else. Therefore, calling
event.stopPropagation()
andevent.preventDefault()
to prevent all other actions should have no negative side effects.Manual testing scenarios (*)
A dirty way to add a copy button to a grid would be to edit Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Datetime::render() and add the line
$data = '<span data-copy-text="' . $data . '">' . $data . '</span>';
right before the
return $data;
, like thisThis adds a copy button to the date column in the orders grid
Clicking the copy button copies the date. But it also navigates to the order details. With this PR applied, it only copies the date.
Contribution checklist (*)