Skip to content
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

Merged
merged 4 commits into from
Apr 21, 2020

Conversation

elizabetdev
Copy link
Contributor

@elizabetdev elizabetdev commented Apr 20, 2020

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
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • [ ] Added documentation examples
  • [ ] Added or updated jest tests
  • [ ] Checked for breaking changes and labeled appropriately
  • [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3351/

@elizabetdev
Copy link
Contributor Author

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3351/

Copy link
Contributor

@chandlerprall chandlerprall left a 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.

@elizabetdev
Copy link
Contributor Author

Thanks, @Chandler. I've just updated the code with what you suggested. I tested and it's working!

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3351/

Copy link
Contributor

@chandlerprall chandlerprall left a 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

@elizabetdev elizabetdev merged commit 8fa9243 into elastic:master Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EuiCodeBlock does not update the value in to copy to clipboard
3 participants