File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Expand file tree Collapse file tree 2 files changed +31
-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,26 @@ describe('legend interaction', function() {
16391641 } ) ;
16401642 } ) ;
16411643} ) ;
1644+
1645+ describe ( 'legend DOM' , function ( ) {
1646+ 'use strict' ;
1647+
1648+ it ( 'draws `legendtoggle` last to make sure it is unobstructed' , function ( done ) {
1649+ var gd = createGraphDiv ( ) ;
1650+ Plotly . newPlot ( gd , mock )
1651+ . then ( function ( ) {
1652+ // Find legend in figure
1653+ var legend = document . getElementsByClassName ( 'legend' ) [ 0 ] ;
1654+
1655+ // For each legend item
1656+ var legendItems = legend . getElementsByClassName ( 'traces' ) ;
1657+ Array . prototype . slice . call ( legendItems ) . forEach ( function ( legendItem ) {
1658+ // Check that the last element is our `legendtoggle`
1659+ var lastEl = legendItem . children [ legendItem . children . length - 1 ] ;
1660+ expect ( lastEl . getAttribute ( 'class' ) ) . toBe ( 'legendtoggle' ) ;
1661+ } ) ;
1662+ } )
1663+ . catch ( failTest )
1664+ . then ( done ) ;
1665+ } ) ;
1666+ } ) ;
You can’t perform that action at this time.
0 commit comments