-
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
[EuiIcon]: Add appendIconComponentCache function #3481
[EuiIcon]: Add appendIconComponentCache function #3481
Conversation
* Add appendIconComponentCache function to complement the recently-added clearIconComponentCache function. Use case is to work around issues with the dynamic loading: if an icon is not in the cache, an attempt is made to fetch it dynamically, however some environments (such as using certain bundlers, like Parcel: parcel-bundler/parcel#112) do not transpile this functionality correctly. Being able to manually manipulate the icon cache allows a work around for this issue.
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
💚 CLA has been signed |
I like this idea! Have you tested this change with parcel? (Also, as our cla check service mentioned, please sign our Contributor Agreement using the email address associated with your github account. We can't accept a pull request without this) |
@chandlerprall I've tested this with Parcel, solves the issue I was facing in my own project. Here is some sample usage (preloading icons used in the EuiInMemoryTable component):
Once I saw the @cla-checker-service message above, I signed the CLA (not sure if the process is automatic or if it needs to be manually processed). Thanks, |
Although it doesn't directly solve the issue, this addition also might assist with cases like #2467 |
I threw a PR your way to clean this up a bit - wonderscore#1 Went with the PR route instead of requesting changes as the tests & documentation itself didn't feel like straight-forward asks. One thought I had, given your example, is if the function should instead take an object of |
… function: One or more icon(s) are passed in as an object of iconKey (string): IconComponent
Merged back into this PR.
Good idea, implemented in this PR. |
jenkins test this |
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.
Changes look good! Let's add two things and this should be good to merge in
- needs an entry at the top of CHANGELOG.md mentioning the new function and referencing this PR
appendIconComponentCache
should get a mock entry in icon.testenv.tsx - this file is provided for applications using EUI (such as Kibana) to automatically mock functionality those apps shouldn't care about - like all this dynamic loading - but it needs to have the same API as the source file.
Preview documentation changes for this PR: https://eui.elastic.co/pr_3481/ |
* Define an empty no-op mock of the `appendIconComponentCache` function in icon.testenv.tsx * Update the main CHANGELOG.md with a summary of the new `appendIconComponentCache` EuiIcon feature.
jenkins test this |
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.
Changes LGTM! Will merge on green CI.
Preview documentation changes for this PR: https://eui.elastic.co/pr_3481/ |
known flaky unit test jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3481/ |
Different flaky reason. jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3481/ |
@chandlerprall this is a small extension to your recent caching changes to EuiIcon in #3404
Use case is to work around issues with the dynamic loading: if an icon is not in the cache, an attempt is made to fetch it dynamically, however some environments (such as using certain bundlers, like Parcel: parcel-bundler/parcel#112) do not transpile this functionality correctly.
Being able to manually manipulate the icon cache allows a work around for this issue.
Summary
Provide a detailed summary of your PR. Explain how you arrived at your solution. If it includes changes to UI elements include a screenshot or gif.
Checklist