@@ -1089,7 +1089,7 @@ describe('Activate and edit editable shapes', function() {
10891089 afterEach ( destroyGraphDiv ) ;
10901090
10911091 [ 'mouse' ] . forEach ( function ( device ) {
1092- it ( '@flaky reactangle using' + device , function ( done ) {
1092+ it ( '@flaky reactangle using ' + device , function ( done ) {
10931093 var i = 0 ; // shape index
10941094
10951095 Plotly . newPlot ( gd , {
@@ -1224,7 +1224,7 @@ describe('Activate and edit editable shapes', function() {
12241224 . then ( done ) ;
12251225 } ) ;
12261226
1227- it ( '@flaky circle using' + device , function ( done ) {
1227+ it ( '@flaky circle using ' + device , function ( done ) {
12281228 var i = 1 ; // shape index
12291229
12301230 Plotly . newPlot ( gd , {
@@ -1281,7 +1281,7 @@ describe('Activate and edit editable shapes', function() {
12811281 . then ( done ) ;
12821282 } ) ;
12831283
1284- it ( '@flaky closed-path using' + device , function ( done ) {
1284+ it ( '@flaky closed-path using ' + device , function ( done ) {
12851285 var i = 2 ; // shape index
12861286
12871287 Plotly . newPlot ( gd , {
@@ -1326,7 +1326,7 @@ describe('Activate and edit editable shapes', function() {
13261326 . then ( done ) ;
13271327 } ) ;
13281328
1329- it ( '@flaky bezier curves using' + device , function ( done ) {
1329+ it ( '@flaky bezier curves using ' + device , function ( done ) {
13301330 var i = 5 ; // shape index
13311331
13321332 Plotly . newPlot ( gd , {
@@ -1371,7 +1371,7 @@ describe('Activate and edit editable shapes', function() {
13711371 . then ( done ) ;
13721372 } ) ;
13731373
1374- it ( '@flaky multi-cell path using' + device , function ( done ) {
1374+ it ( '@flaky multi-cell path using ' + device , function ( done ) {
13751375 var i = 6 ; // shape index
13761376
13771377 Plotly . newPlot ( gd , {
@@ -1426,3 +1426,123 @@ describe('Activate and edit editable shapes', function() {
14261426 } ) ;
14271427 } ) ;
14281428} ) ;
1429+
1430+
1431+ describe ( 'Activate and edit editable shapes' , function ( ) {
1432+ var gd ;
1433+
1434+ beforeEach ( function ( ) {
1435+ gd = createGraphDiv ( ) ;
1436+ } ) ;
1437+
1438+ afterEach ( destroyGraphDiv ) ;
1439+
1440+ it ( 'should not set pointer-events for non-editable shapes i.e. to allow pan/zoom/hover work inside shapes' , function ( done ) {
1441+ Plotly . newPlot ( gd , {
1442+ data : [ {
1443+ mode : 'markers' ,
1444+ x : [ 1 , 3 , 3 ] ,
1445+ y : [ 2 , 1 , 3 ]
1446+ } ] ,
1447+ layout : {
1448+ shapes : [
1449+ {
1450+ x0 : 1.5 ,
1451+ x1 : 2.5 ,
1452+ y0 : 1.5 ,
1453+ y1 : 2.5 ,
1454+ fillcolor : 'blue'
1455+ }
1456+ ]
1457+ }
1458+ } )
1459+
1460+ . then ( function ( ) {
1461+ var el = Plotly . d3 . selectAll ( '.shapelayer path' ) [ 0 ] [ 0 ] ;
1462+ var pointerEvents = el . style [ 'pointer-events' ] ;
1463+ expect ( pointerEvents ) . not . toBe ( 'all' ) ;
1464+ expect ( pointerEvents ) . not . toBe ( 'stroke' ) ;
1465+ expect ( pointerEvents ) . toBe ( '' ) ;
1466+ } )
1467+
1468+ . catch ( failTest )
1469+ . then ( done ) ;
1470+ } ) ;
1471+
1472+ it ( 'should provide invisible border & set pointer-events to "stroke" for editable shapes i.e. to allow shape activation' , function ( done ) {
1473+ Plotly . newPlot ( gd , {
1474+ data : [ {
1475+ mode : 'markers' ,
1476+ x : [ 1 , 3 , 3 ] ,
1477+ y : [ 2 , 1 , 3 ]
1478+ } ] ,
1479+ layout : {
1480+ shapes : [
1481+ {
1482+ editable : true ,
1483+ x0 : 1.5 ,
1484+ x1 : 2.5 ,
1485+ y0 : 1.5 ,
1486+ y1 : 2.5 ,
1487+ fillcolor : 'blue' ,
1488+ line : {
1489+ width : 0 ,
1490+ dash : 'dash' ,
1491+ color : 'black'
1492+ }
1493+ }
1494+ ]
1495+ }
1496+ } )
1497+
1498+ . then ( function ( ) {
1499+ var el = Plotly . d3 . selectAll ( '.shapelayer path' ) [ 0 ] [ 0 ] ;
1500+ expect ( el . style [ 'pointer-events' ] ) . toBe ( 'stroke' ) ;
1501+ expect ( el . style . stroke ) . toBe ( 'rgb(0, 0, 0)' ) ; // no color
1502+ expect ( el . style [ 'stroke-opacity' ] ) . toBe ( '0' ) ; // invisible
1503+ expect ( el . style [ 'stroke-width' ] ) . toBe ( '5px' ) ; // some pixels to activate shape
1504+ } )
1505+
1506+ . catch ( failTest )
1507+ . then ( done ) ;
1508+ } ) ;
1509+
1510+ it ( 'should not provide invisible border & set pointer-events to "stroke" for shapes made editable via config' , function ( done ) {
1511+ Plotly . newPlot ( gd , {
1512+ data : [ {
1513+ mode : 'markers' ,
1514+ x : [ 1 , 3 , 3 ] ,
1515+ y : [ 2 , 1 , 3 ]
1516+ } ] ,
1517+ layout : {
1518+ shapes : [
1519+ {
1520+ x0 : 1.5 ,
1521+ x1 : 2.5 ,
1522+ y0 : 1.5 ,
1523+ y1 : 2.5 ,
1524+ fillcolor : 'blue' ,
1525+ line : {
1526+ width : 0 ,
1527+ dash : 'dash' ,
1528+ color : 'black'
1529+ }
1530+ }
1531+ ]
1532+ } , onfig : {
1533+ editable : true
1534+ }
1535+ } )
1536+
1537+ . then ( function ( ) {
1538+ var el = Plotly . d3 . selectAll ( '.shapelayer path' ) [ 0 ] [ 0 ] ;
1539+ expect ( el . style [ 'pointer-events' ] ) . toBe ( '' ) ;
1540+ expect ( el . style . stroke ) . toBe ( 'rgb(0, 0, 0)' ) ; // no color
1541+ expect ( el . style [ 'stroke-opacity' ] ) . toBe ( '0' ) ; // invisible
1542+ expect ( el . style [ 'stroke-width' ] ) . toBe ( '0px' ) ; // no extra pixels
1543+ } )
1544+
1545+ . catch ( failTest )
1546+ . then ( done ) ;
1547+ } ) ;
1548+ } ) ;
0 commit comments