You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If you pass an isCopyable prop to EuiCodeBlock it should render a text copy button. However, in Safari, the copy button isn't shown when you use EuiCodeBlock as an expandable table row. But it does work properly in other cases.
Additional context
I tried to dig into this bug a little, and here's what I found.
EuiCodeBlock component uses useInnerText 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.
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 when innerText becomes readable, so it thinks the value stays ''. Interestingly, textContent and innerHTML values can be read right away.
I tried logging values of innerText, textContent and innerHTML immediately after expanding the row.
❌ Safari: innerText is empty initially, but has value if you read it a little later. textContent and innerHTML 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 either EuiTableRow wrapper or EuiTableRowCell wrapper, the copy button is rendered!
Describe the bug
If you pass an
isCopyableprop toEuiCodeBlockit should render a text copy button. However, in Safari, the copy button isn't shown when you useEuiCodeBlockas 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.
EuiCodeBlockcomponent usesuseInnerTexthook under the hood. As I understand,useInnerTextworks like this: you give it a ref, and it reads that ref's.innerTextvalue 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 (
innerTextvalue 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
innerTextis an empty string (Safari bug?). But if you re-query it within a few moments, you'll get the proper value.useInnerTextdoesn't get notified wheninnerTextbecomes readable, so it thinks the value stays''. Interestingly,textContentandinnerHTMLvalues can be read right away.I tried logging values of
innerText,textContentandinnerHTMLimmediately after expanding the row.❌ Safari:

innerTextis empty initially, but has value if you read it a little later.textContentandinnerHTMLare 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
EuiBasicTablecode to change how expanded row is rendered. If you remove eitherEuiTableRowwrapper orEuiTableRowCellwrapper, 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:
textContentinstead ofinnerText, so that it's compatible with Safari behavior?EuiCodeBlock?