-
Notifications
You must be signed in to change notification settings - Fork 121
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
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.
|
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!
@@ -76,6 +76,10 @@ class Chart extends React.Component<ReactiveChartProps, ReactiveChartState> { | |||
}, | |||
}; | |||
|
|||
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
onBrushEnd
callback triggers a URL change and thus a rerender of the page andChart
components on the page. The workaround solution was to add a500ms
setTimeout
to allow time for the state to update before calling theonBrushEnd
callback.The solution as suggested by @FrankHassanabad, is to invoke the
onBrushEnd
callback following the completion of thesetState
method.fixes #360
Screenshot
Notice no console errors when brushing chart and successful update of time range and chart.
Additionally, added
componentWillUnmount
method to ensurewindow.removeEventListener
is called onmouseup
event in the case where theChart
is unmounted before this event is called.Checklist