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 and improve Plotly event handling #6753

Merged
merged 3 commits into from
Apr 18, 2024
Merged

Conversation

philippjfr
Copy link
Member

After a ton of investigation I found that click event handling depends on the following sequence of events, which for some reason does not occur in the right sequence in our case (likely due to the shadow DOM):

  1. Hover event data is captured and set on the Plotly container element
  2. The click event handler checks if the hoverdata is present and only dispatches a click event if that's the case
  3. On unhover the hoverdata is reset.

In our case steps 2 and 3 were switched causing click events not to be dispatched. In this PR we do a few things:

  1. Temporarily patch the hoverdata to ensure it is present when the click handler expects it
  2. Convert the various <event_data> bokeh properties into bokeh events, ensuring that the same event can be sent multiple times.

Fixes #5096

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Attention: Patch coverage is 56.52174% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 37.24%. Comparing base (76c911a) to head (4c8ea0a).
Report is 16 commits behind head on main.

Files Patch % Lines
panel/pane/plotly.py 11.11% 8 Missing ⚠️
panel/models/plotly.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6753      +/-   ##
==========================================
- Coverage   40.01%   37.24%   -2.78%     
==========================================
  Files         313      314       +1     
  Lines       46194    46310     +116     
==========================================
- Hits        18486    17246    -1240     
- Misses      27708    29064    +1356     
Flag Coverage Δ
ui-tests 37.24% <56.52%> (-2.78%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@philippjfr philippjfr merged commit e1d901b into main Apr 18, 2024
11 of 15 checks passed
@philippjfr philippjfr deleted the plotly_event_handling branch April 18, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken click_data event on plotly data point since panel 1.x.x
1 participant