-
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
Fix EuiCodeBlock not copying updated content #3351
Fix EuiCodeBlock not copying updated content #3351
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_3351/ |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3351/ |
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.
Thanks for taking this!
I was curious why EuiInnerText's mutation observer wasn't catching these changes, and a new one had to be created every time - wanted to know if this was somehow unique to code blocks or a bug in useInnerText. Turns out its mutation observer configuration is missing childList: true
.
Had to dig into the difference between childList
and subtree
: subtree
applies the configuration & observer to the existing elements, while childList
instructs the observer to update when elements are added or removed from the tree. useInnerText needs both.
Thanks, @Chandler. I've just updated the code with what you suggested. I tested and it's working! |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3351/ |
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.
Thanks! Change LGTM; pulled & tested locally
Summary
Closes #3321.
This PR tries to fix the bug with the EuiCodeBlock does not seem to update the value to copy when the content changes. To fix this bug, a unique key was added to the
EuiInnerText
. Every time the content changes a new key is generated so this makes possible to copy the new content.Checklist
[ ] Check against all themes for compatibility in both light and dark modes[ ] Checked in mobile[ ] Added documentation examples[ ] Added or updated jest tests[ ] Checked for breaking changes and labeled appropriately[ ] Checked for accessibility including keyboard-only and screenreader modes