File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -118,10 +118,13 @@ module.exports = function draw(gd) {
118118 } )
119119 . each ( function ( ) {
120120 d3 . select ( this )
121- . call ( drawTexts , gd , maxLength )
122- . call ( setupTraceToggle , gd ) ;
121+ . call ( drawTexts , gd , maxLength ) ;
123122 } )
124- . call ( style , gd ) ;
123+ . call ( style , gd )
124+ . each ( function ( ) {
125+ d3 . select ( this )
126+ . call ( setupTraceToggle , gd ) ;
127+ } ) ;
125128
126129 Lib . syncOrAsync ( [ Plots . previousPromises ,
127130 function ( ) {
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ var createGraphDiv = require('../assets/create_graph_div');
1515var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
1616var assertPlotSize = require ( '../assets/custom_assertions' ) . assertPlotSize ;
1717
18+ var mock = require ( '@mocks/legend_horizontal.json' ) ;
19+
1820var Drawing = require ( '@src/components/drawing' ) ;
1921
2022describe ( 'legend defaults' , function ( ) {
@@ -1639,3 +1641,28 @@ describe('legend interaction', function() {
16391641 } ) ;
16401642 } ) ;
16411643} ) ;
1644+
1645+ describe ( 'legend DOM' , function ( ) {
1646+ 'use strict' ;
1647+
1648+ afterEach ( destroyGraphDiv ) ;
1649+
1650+ it ( 'draws `legendtoggle` last to make sure it is unobstructed' , function ( done ) {
1651+ var gd = createGraphDiv ( ) ;
1652+ Plotly . newPlot ( gd , mock )
1653+ . then ( function ( ) {
1654+ // Find legend in figure
1655+ var legend = document . getElementsByClassName ( 'legend' ) [ 0 ] ;
1656+
1657+ // For each legend item
1658+ var legendItems = legend . getElementsByClassName ( 'traces' ) ;
1659+ Array . prototype . slice . call ( legendItems ) . forEach ( function ( legendItem ) {
1660+ // Check that the last element is our `legendtoggle`
1661+ var lastEl = legendItem . children [ legendItem . children . length - 1 ] ;
1662+ expect ( lastEl . getAttribute ( 'class' ) ) . toBe ( 'legendtoggle' ) ;
1663+ } ) ;
1664+ } )
1665+ . catch ( failTest )
1666+ . then ( done ) ;
1667+ } ) ;
1668+ } ) ;
You can’t perform that action at this time.
0 commit comments