@@ -1089,7 +1089,7 @@ describe('Activate and edit editable shapes', function() {
1089
1089
afterEach ( destroyGraphDiv ) ;
1090
1090
1091
1091
[ 'mouse' ] . forEach ( function ( device ) {
1092
- it ( '@flaky reactangle using' + device , function ( done ) {
1092
+ it ( '@flaky reactangle using ' + device , function ( done ) {
1093
1093
var i = 0 ; // shape index
1094
1094
1095
1095
Plotly . newPlot ( gd , {
@@ -1224,7 +1224,7 @@ describe('Activate and edit editable shapes', function() {
1224
1224
. then ( done ) ;
1225
1225
} ) ;
1226
1226
1227
- it ( '@flaky circle using' + device , function ( done ) {
1227
+ it ( '@flaky circle using ' + device , function ( done ) {
1228
1228
var i = 1 ; // shape index
1229
1229
1230
1230
Plotly . newPlot ( gd , {
@@ -1281,7 +1281,7 @@ describe('Activate and edit editable shapes', function() {
1281
1281
. then ( done ) ;
1282
1282
} ) ;
1283
1283
1284
- it ( '@flaky closed-path using' + device , function ( done ) {
1284
+ it ( '@flaky closed-path using ' + device , function ( done ) {
1285
1285
var i = 2 ; // shape index
1286
1286
1287
1287
Plotly . newPlot ( gd , {
@@ -1326,7 +1326,7 @@ describe('Activate and edit editable shapes', function() {
1326
1326
. then ( done ) ;
1327
1327
} ) ;
1328
1328
1329
- it ( '@flaky bezier curves using' + device , function ( done ) {
1329
+ it ( '@flaky bezier curves using ' + device , function ( done ) {
1330
1330
var i = 5 ; // shape index
1331
1331
1332
1332
Plotly . newPlot ( gd , {
@@ -1371,7 +1371,7 @@ describe('Activate and edit editable shapes', function() {
1371
1371
. then ( done ) ;
1372
1372
} ) ;
1373
1373
1374
- it ( '@flaky multi-cell path using' + device , function ( done ) {
1374
+ it ( '@flaky multi-cell path using ' + device , function ( done ) {
1375
1375
var i = 6 ; // shape index
1376
1376
1377
1377
Plotly . newPlot ( gd , {
@@ -1426,3 +1426,123 @@ describe('Activate and edit editable shapes', function() {
1426
1426
} ) ;
1427
1427
} ) ;
1428
1428
} ) ;
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