-
Notifications
You must be signed in to change notification settings - Fork 842
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
EuiCodeBlock doesn't have a "Copy" button is Safari when rendered in EuiBasicTable's expandable row #6770
Comments
Thank you so much for the detailed bug report, Nikita! It's seriously appreciated! I also love the time you took to grok the underlying issue & to suggest fixes. It looks like eui/src/components/inner_text/inner_text.tsx Lines 29 to 36 in c85913b
I wonder if the comment in the above linked code still applies - it's possible it doesn't and we can now simply do a The other optional vectors for failure are:
I think your third suggestion, providing a copy fallback for EuiCodeBlock, would be a last resort option & will work, but we should try and figure out why Safari is failing first. |
@tkajtoch would this be something you'd be interested in investigating / spiking out since you already potentially have another fix in the work for a separate bug w/ EuiCodeBlock's copy behavior? |
I reproduced this in a minimal CodeSandbox if it's helpful for hacking against. https://codesandbox.io/s/stupefied-galileo-o8kn75?file=/demo.tsx |
@tkajtoch It's a long shot, but I found a SO question Reactjs web app - MutationObserver use in Safari browser not as expected that has some of the same extenuating circumstances as this issue. The OP could see the expected outcome when they inspected their text area, couple of others. Might be nothing, might be a lead. 🤞 |
There are a few differences between Actually, because of that behavior I'd like to check if this issue isn't caused by asynchronous style updates that Safari somehow takes longer to process and extract text from child nodes. |
…o much space (#157271) ## Summary When a large "last execution" error message is displayed on Rule Details page it takes too much vertical space: https://user-images.githubusercontent.com/2946766/214444343-dde0d9cd-6bc7-4aca-a6cf-07891d206888.png This PR changes the error callout component. Error text is now displayed using EUI's TextBlock component. Users will see a scroll if error text takes too much vertical space. Now it's also possible to view the text fullscreen or copy it to clipboard. <img width="1206" alt="Screenshot 2023-05-10 at 16 16 40" src="https://github.com/elastic/kibana/assets/15949146/bca81852-afa0-44f6-acad-51c7c60c8a6f"> --- Another addition is a button to expand a row in the Execution Log to view / copy a full error message. <img width="1179" alt="Screenshot 2023-05-10 at 16 15 16" src="https://github.com/elastic/kibana/assets/15949146/624e3fdc-8dd7-4fa1-a8a6-b1608be17eec"> ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) **Known issue**: Copy button is not shown in Execution Log expandable row in Safari. Opened an issue in EUI: elastic/eui#6770
…o much space (elastic#157271) ## Summary When a large "last execution" error message is displayed on Rule Details page it takes too much vertical space: https://user-images.githubusercontent.com/2946766/214444343-dde0d9cd-6bc7-4aca-a6cf-07891d206888.png This PR changes the error callout component. Error text is now displayed using EUI's TextBlock component. Users will see a scroll if error text takes too much vertical space. Now it's also possible to view the text fullscreen or copy it to clipboard. <img width="1206" alt="Screenshot 2023-05-10 at 16 16 40" src="https://github.com/elastic/kibana/assets/15949146/bca81852-afa0-44f6-acad-51c7c60c8a6f"> --- Another addition is a button to expand a row in the Execution Log to view / copy a full error message. <img width="1179" alt="Screenshot 2023-05-10 at 16 15 16" src="https://github.com/elastic/kibana/assets/15949146/624e3fdc-8dd7-4fa1-a8a6-b1608be17eec"> ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) **Known issue**: Copy button is not shown in Execution Log expandable row in Safari. Opened an issue in EUI: elastic/eui#6770 (cherry picked from commit f214b55)
…ing too much space (#157271) (#158079) # Backport This will backport the following commits from `main` to `8.8`: - [[Security Solution] Fix error messages on Rule Details page taking too much space (#157271)](#157271) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nikita Indik","email":"nikita.indik@elastic.co"},"sourceCommit":{"committedDate":"2023-05-18T13:38:03Z","message":"[Security Solution] Fix error messages on Rule Details page taking too much space (#157271)\n\n## Summary\r\n\r\nWhen a large \"last execution\" error message is displayed on Rule Details\r\npage it takes too much vertical space:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/2946766/214444343-dde0d9cd-6bc7-4aca-a6cf-07891d206888.png\r\n\r\nThis PR changes the error callout component. Error text is now displayed\r\nusing EUI's TextBlock component. Users will see a scroll if error text\r\ntakes too much vertical space. Now it's also possible to view the text\r\nfullscreen or copy it to clipboard.\r\n\r\n<img width=\"1206\" alt=\"Screenshot 2023-05-10 at 16 16 40\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/bca81852-afa0-44f6-acad-51c7c60c8a6f\">\r\n\r\n ---\r\n\r\nAnother addition is a button to expand a row in the Execution Log to\r\nview / copy a full error message.\r\n<img width=\"1179\" alt=\"Screenshot 2023-05-10 at 16 15 16\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/624e3fdc-8dd7-4fa1-a8a6-b1608be17eec\">\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n- [x] Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n- [x] This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n### For maintainers\r\n\r\n- [x] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n\r\n**Known issue**: Copy button is not shown in Execution Log expandable\r\nrow in Safari. Opened an issue in EUI:\r\nhttps://github.com/elastic/eui/issues/6770","sha":"f214b55704dd9c300be845530de956a27fd12bab","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Detections and Resp","Feature:Rule Monitoring","Team:Security Solution Platform","Team:Detection Rule Management","Feature:Rule Details","backport:prev-minor","v8.9.0"],"number":157271,"url":"https://github.com/elastic/kibana/pull/157271","mergeCommit":{"message":"[Security Solution] Fix error messages on Rule Details page taking too much space (#157271)\n\n## Summary\r\n\r\nWhen a large \"last execution\" error message is displayed on Rule Details\r\npage it takes too much vertical space:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/2946766/214444343-dde0d9cd-6bc7-4aca-a6cf-07891d206888.png\r\n\r\nThis PR changes the error callout component. Error text is now displayed\r\nusing EUI's TextBlock component. Users will see a scroll if error text\r\ntakes too much vertical space. Now it's also possible to view the text\r\nfullscreen or copy it to clipboard.\r\n\r\n<img width=\"1206\" alt=\"Screenshot 2023-05-10 at 16 16 40\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/bca81852-afa0-44f6-acad-51c7c60c8a6f\">\r\n\r\n ---\r\n\r\nAnother addition is a button to expand a row in the Execution Log to\r\nview / copy a full error message.\r\n<img width=\"1179\" alt=\"Screenshot 2023-05-10 at 16 15 16\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/624e3fdc-8dd7-4fa1-a8a6-b1608be17eec\">\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n- [x] Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n- [x] This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n### For maintainers\r\n\r\n- [x] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n\r\n**Known issue**: Copy button is not shown in Execution Log expandable\r\nrow in Safari. Opened an issue in EUI:\r\nhttps://github.com/elastic/eui/issues/6770","sha":"f214b55704dd9c300be845530de956a27fd12bab"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/157271","number":157271,"mergeCommit":{"message":"[Security Solution] Fix error messages on Rule Details page taking too much space (#157271)\n\n## Summary\r\n\r\nWhen a large \"last execution\" error message is displayed on Rule Details\r\npage it takes too much vertical space:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/2946766/214444343-dde0d9cd-6bc7-4aca-a6cf-07891d206888.png\r\n\r\nThis PR changes the error callout component. Error text is now displayed\r\nusing EUI's TextBlock component. Users will see a scroll if error text\r\ntakes too much vertical space. Now it's also possible to view the text\r\nfullscreen or copy it to clipboard.\r\n\r\n<img width=\"1206\" alt=\"Screenshot 2023-05-10 at 16 16 40\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/bca81852-afa0-44f6-acad-51c7c60c8a6f\">\r\n\r\n ---\r\n\r\nAnother addition is a button to expand a row in the Execution Log to\r\nview / copy a full error message.\r\n<img width=\"1179\" alt=\"Screenshot 2023-05-10 at 16 15 16\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/624e3fdc-8dd7-4fa1-a8a6-b1608be17eec\">\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n- [x] Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n- [x] This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n### For maintainers\r\n\r\n- [x] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n\r\n**Known issue**: Copy button is not shown in Execution Log expandable\r\nrow in Safari. Opened an issue in EUI:\r\nhttps://github.com/elastic/eui/issues/6770","sha":"f214b55704dd9c300be845530de956a27fd12bab"}}]}] BACKPORT--> Co-authored-by: Nikita Indik <nikita.indik@elastic.co>
…o much space (elastic#157271) ## Summary When a large "last execution" error message is displayed on Rule Details page it takes too much vertical space: https://user-images.githubusercontent.com/2946766/214444343-dde0d9cd-6bc7-4aca-a6cf-07891d206888.png This PR changes the error callout component. Error text is now displayed using EUI's TextBlock component. Users will see a scroll if error text takes too much vertical space. Now it's also possible to view the text fullscreen or copy it to clipboard. <img width="1206" alt="Screenshot 2023-05-10 at 16 16 40" src="https://github.com/elastic/kibana/assets/15949146/bca81852-afa0-44f6-acad-51c7c60c8a6f"> --- Another addition is a button to expand a row in the Execution Log to view / copy a full error message. <img width="1179" alt="Screenshot 2023-05-10 at 16 15 16" src="https://github.com/elastic/kibana/assets/15949146/624e3fdc-8dd7-4fa1-a8a6-b1608be17eec"> ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) **Known issue**: Copy button is not shown in Execution Log expandable row in Safari. Opened an issue in EUI: elastic/eui#6770
Describe the bug
If you pass an
isCopyable
prop toEuiCodeBlock
it should render a text copy button. However, in Safari, the copy button isn't shown when you useEuiCodeBlock
as an expandable table row. But it does work properly in other cases.Environment and versions
To Reproduce
Steps to reproduce the behavior:
Expected behavior
TextBlock's copy button should be visible in Safari when TextBlock is rendered within EuiBasicTable's expandable row.
Screenshots

❌ Safari: Expandable row in Execution log - no copy button
✅ Chrome: Expandable row in Execution log - copy button present

✅ Safari: Warning callout - copy button present

✅ Chrome: Warning callout - copy button present

Additional context
I tried to dig into this bug a little, and here's what I found.
EuiCodeBlock
component usesuseInnerText
hook under the hood. As I understand,useInnerText
works like this: you give it a ref, and it reads that ref's.innerText
value initially and on every update.eui/src/components/inner_text/inner_text.tsx
Line 19 in c85913b
And there's conditional logic: if there's no text to copy (
innerText
value is falsy) - do not render the button. That's what happens in Safari.eui/src/components/code/code_block_copy.tsx
Line 34 in 8081fda
For some reason in Safari, during an initial render, the value of
innerText
is an empty string (Safari bug?). But if you re-query it within a few moments, you'll get the proper value.useInnerText
doesn't get notified wheninnerText
becomes readable, so it thinks the value stays''
. Interestingly,textContent
andinnerHTML
values can be read right away.I tried logging values of
innerText
,textContent
andinnerHTML
immediately after expanding the row.❌ Safari:

innerText
is empty initially, but has value if you read it a little later.textContent
andinnerHTML
are readable right away.✅ Chrome: all three properties can be read right away

Safari: If you trigger a text update, useInnerText's observer would fire and you'll see the copy button.
Screen.Recording.2023-05-11.at.15.47.24.mov
I also tried modifying
EuiBasicTable
code to change how expanded row is rendered. If you remove eitherEuiTableRow
wrapper orEuiTableRowCell
wrapper, the copy button is rendered!eui/src/components/basic_table/basic_table.tsx
Line 1036 in dc3fcbc
✅ Safari: Without

EuiTableRow
- no opening animation, but copy button is renderedSo maybe it's connected to Safari handling animated elements differently somehow 🤷♀️
Possible fix ideas:
textContent
instead ofinnerText
, so that it's compatible with Safari behavior?EuiCodeBlock
?The text was updated successfully, but these errors were encountered: