-
Notifications
You must be signed in to change notification settings - Fork 841
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
fix(EuiCode): fix code block copy button not including the last character #6794
fix(EuiCode): fix code block copy button not including the last character #6794
Conversation
805ec38
to
07d8cdf
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_6794/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current implementation works great in Safari, Firefox, Chrome, Edge.
All browsers except Firefox dropped the cursor at the end of the copied block. Firefox dropped the cursor on a newline, but that might be a browser detail? LMK if you want a second run through if/when you remove the second .replace()
in code_block_copy.tsx.
aac77e3
to
a1e0d93
Compare
@1Copenut I just checked the copy behavior on Firefox and I couldn't replicate what you found. Do you remember what code block generated that new line when copying on Firefox? |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6794/ |
@tkajtoch As best I can recall, all of the blocks added that newline in MacOS Monterey, running latest Firefox. It was a consistent behavior for the popover, virtualized, multiline, and one-line copy examples. |
Actually, I can repro, sorry:
That came from the The HTML and JSON copyable examples work just fine however 💀 EDIT: This is also happening on Edge so I think this seems to specifically affect the whitespace behavior, and might have been why the |
a1e0d93
to
de36c35
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_6794/ |
Thanks Tomasz - I can confirm the I'd like to see tests of some kind (looks like you could try RTL for clipboard assertions, if not I'd use Cypress) that assert the following:
|
Update to the above comment - I ended up adding the base for Cypress copy tests in #6824 while fixing another copy bug. I also went a little overboard and added a TODO regression test in that PR for this PR 😅 Once that PR lands, you should be able to go ahead and merge it in and remove/uncomment the last assertion to confirm that this now behaves as expected. |
…cter if it's a question mark
…a single one when using the Copy button This change was first introduced in 7aeb30f ([EuiCodeBlock] Replace highlight.js with prism.js via refractor (elastic#4638)) but doesn't seem to be a business or product decision. We decided to remove it to make the copied content match what's displayed on screen.
…ines to a single one when using the Copy button" This reverts commit 8a90215c81432514493b1bb29ecd314d6792a05d.
de36c35
to
91823c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
Preview documentation changes for this PR: https://eui.elastic.co/pr_6794/ |
This is a backport EUI upgrade to Kibana v8.8.1 containing an `EuiCodeBlock` bugfix requested by the Observability team: #158644 (comment) ## [`77.1.5`](https://github.com/elastic/eui/tree/v77.1.5) **Bug fixes** - Fixed `EuiCodeBlock` potentially incorrectly ignoring lines ending with a question mark when using the Copy button. ([#6794](elastic/eui#6794)) - Fixed `EuiCodeBlock` to not include line numbers when copying content ([#6824](elastic/eui#6824)) - Fixed the expanded row animation on `EuiBasicTable` causing cross-browser Safari issues ([#6826](elastic/eui#6826)) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
## Summary `eui@81.2.0` ⏩ `eui@81.3.0` ✨ Highlights: - fixes #158644 - Adds a new Timeline icon for use within `EuiMarkdownEditor` (cc @kqualters-elastic) - Expandable rows used within `EuiBasicTable` and `EuiInMemoryTable` now have a faster and snappier expand animation ___ ## [`81.3.0`](https://github.com/elastic/eui/tree/v81.3.0) - Added `timelineWithArrow` glyph to `EuiIcon` ([#6822](elastic/eui#6822)) **Bug fixes** - Fixed `EuiCodeBlock` potentially incorrectly ignoring lines ending with a question mark when using the Copy button. ([#6794](elastic/eui#6794)) - Fixed `EuiCodeBlock` to not include line numbers when copying content ([#6824](elastic/eui#6824)) - Fixed the expanded row animation on `EuiBasicTable` causing cross-browser Safari issues ([#6826](elastic/eui#6826))
Summary
This PR fixes #6585 that was caused by an incorrect regex being used in
src/components/code/code_block_copy.tsx
. Rest of the replace logic stays the same.QA
General checklist
Checked in both light and dark modesChecked in mobileProps have proper autodocs (using@default
if default values are missing) and playground togglesAdded documentationChecked Code Sandbox works for any docs examplesChecked for breaking changes and labeled appropriatelyChecked for accessibility including keyboard-only and screenreader modesUpdated the Figma library counterpart