-
Notifications
You must be signed in to change notification settings - Fork 129
fix(reactive_chart): fix order of instantiation of onBrushEnd callback #376
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(reactive_chart): fix order of instantiation of onBrushEnd callback #376
Conversation
Wait for setState to finish before calling onBrushEnd, in the event the callback triggers a rerender. fixes elastic#360
Codecov Report
@@ Coverage Diff @@
## master #376 +/- ##
==========================================
+ Coverage 98.25% 98.27% +0.02%
==========================================
Files 38 38
Lines 2801 2784 -17
Branches 661 657 -4
==========================================
- Hits 2752 2736 -16
Misses 44 44
+ Partials 5 4 -1
Continue to review full report at Codecov.
|
markov00
left a comment
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.
LGTM!
|
|
||
| componentWillUnmount() { | ||
| window.removeEventListener('mouseup', this.onEndBrushing); | ||
| } |
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.
❤️
|
🎉 This PR is included in version 12.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [12.0.2](elastic/elastic-charts@v12.0.1...v12.0.2) (2019-09-16) ### Bug Fixes * **reactive_chart:** fix order of instantiation of onBruchEnd callback ([opensearch-project#376](elastic/elastic-charts#376)) ([42cd1e7](elastic/elastic-charts@42cd1e7)), closes [opensearch-project#360](elastic/elastic-charts#360)
Summary
This PR fixes an issue found in SIEM where the
onBrushEndcallback triggers a URL change and thus a rerender of the page andChartcomponents on the page. The workaround solution was to add a500mssetTimeoutto allow time for the state to update before calling theonBrushEndcallback.The solution as suggested by @FrankHassanabad, is to invoke the
onBrushEndcallback following the completion of thesetStatemethod.fixes #360
Screenshot
Notice no console errors when brushing chart and successful update of time range and chart.

Additionally, added
componentWillUnmountmethod to ensurewindow.removeEventListeneris called onmouseupevent in the case where theChartis unmounted before this event is called.Checklist