-
Notifications
You must be signed in to change notification settings - Fork 120
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
feat: add projection click listener #913
feat: add projection click listener #913
Conversation
Codecov Report
@@ Coverage Diff @@
## master #913 +/- ##
==========================================
+ Coverage 70.11% 70.20% +0.08%
==========================================
Files 340 357 +17
Lines 10979 10645 -334
Branches 2382 2163 -219
==========================================
- Hits 7698 7473 -225
+ Misses 3267 3089 -178
- Partials 14 83 +69
Flags with carried forward coverage won't be shown. Click here to find out more.
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 just two comments.
(lastClick, { onProjectionClick }, values): void => { | ||
if (!onProjectionClick) { | ||
return; | ||
} |
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.
is there a way to check if the onElementClick
was called with the same x value, and if so block this from firing?
I'm just thinking about the use case of having the same action fired for both onElementClick
and onProjectionClick
especially with multiple bars. Which could fire the action twice. The user could just debounce the function for 100 ms but I wonder if not firing a duplicate event, namely onProjectionClick
, would be better.
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.
There is a way, we should merge the element and projection click handlers and use a single method to handle both cases. I can check if we can quickly implement that in this PR
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.
Ok, if it's more hassle than it's worth, I think this is fine as is.
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.
done here 5d203f2
🎉 This PR is included in version 24.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [24.2.0](elastic/elastic-charts@v24.1.0...v24.2.0) (2020-11-25) ### Bug Fixes * near and far alignments for orthogonal rotations ([opensearch-project#911](elastic/elastic-charts#911)) ([6b162c6](elastic/elastic-charts@6b162c6)) ### Features * add projection click listener ([opensearch-project#913](elastic/elastic-charts#913)) ([19c14e4](elastic/elastic-charts@19c14e4)), closes [opensearch-project#846](elastic/elastic-charts#846)
Summary
This PR adds a projection click listener called
onProjectionListener
and available in the<Settings />
component with the following characteristics:we don't actually prevent firing theWe prevent theonProjectionListener
if anonElementClick
listener is configured and the user clicks directly on a bar/point. Both events could fire one after the other.onProjectionListener
from firing an event if aonElementClick
listener is available and it has fired a click eventThe type signature of this new listener is the following:
You can enable it through the
<Settings onProjectionListener={yourListenerImplementationHere}/>
The
Interactions -> Bar clicks
story in storybook is updated to fire with this listenerclose #846
Checklist
Delete any items that are not applicable to this PR.
src/index.ts
(and stories only import from../src
except for test data & storybook)