File tree 2 files changed +33
-3
lines changed
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) {
118
118
} )
119
119
. each ( function ( ) {
120
120
d3 . select ( this )
121
- . call ( drawTexts , gd , maxLength )
122
- . call ( setupTraceToggle , gd ) ;
121
+ . call ( drawTexts , gd , maxLength ) ;
123
122
} )
124
- . call ( style , gd ) ;
123
+ . call ( style , gd )
124
+ . each ( function ( ) {
125
+ d3 . select ( this )
126
+ . call ( setupTraceToggle , gd ) ;
127
+ } ) ;
125
128
126
129
Lib . syncOrAsync ( [ Plots . previousPromises ,
127
130
function ( ) {
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ var createGraphDiv = require('../assets/create_graph_div');
15
15
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
16
16
var assertPlotSize = require ( '../assets/custom_assertions' ) . assertPlotSize ;
17
17
18
+ var mock = require ( '@mocks/legend_horizontal.json' ) ;
19
+
18
20
var Drawing = require ( '@src/components/drawing' ) ;
19
21
20
22
describe ( 'legend defaults' , function ( ) {
@@ -1639,3 +1641,28 @@ describe('legend interaction', function() {
1639
1641
} ) ;
1640
1642
} ) ;
1641
1643
} ) ;
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