File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -289,10 +289,18 @@ HTMLWidgets.widget({
289
289
) ;
290
290
} ) ;
291
291
graphDiv . on ( 'plotly_selected' , function ( d ) {
292
- Shiny . onInputChange (
293
- ".clientValue-plotly_selected-" + x . source ,
294
- JSON . stringify ( eventDataWithKey ( d ) )
295
- ) ;
292
+ // If 'plotly_selected' has already been fired, and you click
293
+ // on the plot afterwards, this event fires `undefined`?!?
294
+ // That might be considered a plotly.js bug, but it doesn't make
295
+ // sense for this input change to occur if `d` is falsy because,
296
+ // even in the empty selection case, `d` is truthy (an object),
297
+ // and the 'plotly_deselect' event will reset this input
298
+ if ( d ) {
299
+ Shiny . onInputChange (
300
+ ".clientValue-plotly_selected-" + x . source ,
301
+ JSON . stringify ( eventDataWithKey ( d ) )
302
+ ) ;
303
+ }
296
304
} ) ;
297
305
graphDiv . on ( 'plotly_unhover' , function ( eventData ) {
298
306
Shiny . onInputChange ( ".clientValue-plotly_hover-" + x . source , null ) ;
You can’t perform that action at this time.
0 commit comments