@@ -19,6 +19,7 @@ var svgTextUtils = require('../../lib/svg_text_utils');
1919var anchorUtils = require ( '../legend/anchor_utils' ) ;
2020
2121var constants = require ( './constants' ) ;
22+ var ScrollBox = require ( './scrollbox' ) ;
2223
2324module . exports = function draw ( gd ) {
2425 var fullLayout = gd . _fullLayout ,
@@ -288,6 +289,16 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
288289 index : 0 ,
289290 } ;
290291
292+ var fullLayout = gd . _fullLayout ,
293+ scrollBoxId = 'updatemenus' + fullLayout . _uid + menuOpts . _index ,
294+ scrollBoxPosition = {
295+ l : menuOpts . lx + menuOpts . borderwidth + x0 + menuOpts . pad . l ,
296+ t : menuOpts . ly + menuOpts . borderwidth + y0 + menuOpts . pad . t ,
297+ w : Math . max ( menuOpts . openWidth , menuOpts . headerWidth ) ,
298+ h : menuOpts . openHeight
299+ } ,
300+ scrollBox = new ScrollBox ( gd , gButton , scrollBoxPosition , scrollBoxId ) ;
301+
291302 buttons . each ( function ( buttonOpts , buttonIndex ) {
292303 var button = d3 . select ( this ) ;
293304
@@ -296,10 +307,15 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
296307 . call ( setItemPosition , menuOpts , posOpts ) ;
297308
298309 button . on ( 'click' , function ( ) {
310+ // skip `dragend` events
311+ if ( d3 . event . defaultPrevented ) return ;
312+
299313 setActive ( gd , menuOpts , buttonOpts , gHeader , gButton , buttonIndex ) ;
300314
301315 Plots . executeAPICommand ( gd , buttonOpts . method , buttonOpts . args ) ;
302316
317+ scrollBox . disable ( ) ;
318+
303319 gd . emit ( 'plotly_buttonclicked' , { menu : menuOpts , button : buttonOpts , active : menuOpts . active } ) ;
304320 } ) ;
305321
@@ -314,6 +330,8 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
314330 } ) ;
315331
316332 buttons . call ( styleButtons , menuOpts ) ;
333+
334+ scrollBox . enable ( ) ;
317335}
318336
319337function setActive ( gd , menuOpts , buttonOpts , gHeader , gButton , buttonIndex , isSilentUpdate ) {
0 commit comments