@@ -305,14 +305,6 @@ describe('resizable', () => {
305
305
expect ( Math . floor ( resizedBounds . width ) ) . to . be . eql ( Math . floor ( bounds . width + dx ) ) ;
306
306
} ) ;
307
307
308
- it ( 'should not set bounds again after position is set to absolute' , ( ) => {
309
- const spy = sinon . spy ( dialog . $ . overlay , 'setBounds' ) ;
310
- dispatchMouseEvent ( overlayPart . querySelector ( '.n' ) , 'mousedown' ) ;
311
- dialog . $ . overlay . $ . overlay . style . position = 'absolute' ;
312
- dispatchMouseEvent ( overlayPart . querySelector ( '.n' ) , 'mousedown' ) ;
313
- expect ( spy . calledOnce ) . to . be . true ;
314
- } ) ;
315
-
316
308
it ( 'should dispatch resize event with correct details' , ( ) => {
317
309
const onResize = sinon . spy ( ) ;
318
310
const content = dialog . $ . overlay . $ . content ;
@@ -440,8 +432,9 @@ describe('draggable', () => {
440
432
expect ( Math . floor ( draggedBounds . left ) ) . to . be . eql ( Math . floor ( bounds . left + dx ) ) ;
441
433
} ) ;
442
434
443
- it ( 'should only change "position", "top", and "left" values on drag' , ( ) => {
435
+ it ( 'should only change "position", "top", and "left" values on drag' , async ( ) => {
444
436
drag ( content ) ;
437
+ await nextRender ( ) ;
445
438
const overlay = dialog . $ . overlay . $ . overlay ;
446
439
const style = overlay . style ;
447
440
expect ( style . length ) . to . be . eql ( 3 ) ;
@@ -450,6 +443,18 @@ describe('draggable', () => {
450
443
expect ( style . left ) . to . be . ok ;
451
444
} ) ;
452
445
446
+ it ( 'should assign "top", and "left" properties on drag start' , async ( ) => {
447
+ const overlayBounds = dialog . $ . overlay . getBounds ( ) ;
448
+ expect ( dialog . left ) . to . be . undefined ;
449
+ expect ( dialog . top ) . to . be . undefined ;
450
+
451
+ dispatchMouseEvent ( content , 'mousedown' ) ;
452
+ await nextRender ( ) ;
453
+
454
+ expect ( dialog . left ) . to . be . equal ( overlayBounds . left ) ;
455
+ expect ( dialog . top ) . to . be . equal ( overlayBounds . top ) ;
456
+ } ) ;
457
+
453
458
it ( 'should drag and move dialog if mousedown on element with [class="draggable"] in another shadow root' , async ( ) => {
454
459
drag ( dialog . $ . overlay . querySelector ( 'internally-draggable' ) . shadowRoot . querySelector ( '.draggable' ) ) ;
455
460
await nextRender ( ) ;
@@ -532,7 +537,7 @@ describe('draggable', () => {
532
537
expect ( Math . floor ( draggedBounds . left ) ) . to . be . eql ( Math . floor ( bounds . left ) ) ;
533
538
} ) ;
534
539
535
- it ( 'should not drag dialog if mousedown on .resizer-container scrollbar' , ( ) => {
540
+ it ( 'should not drag dialog if mousedown on .resizer-container scrollbar' , async ( ) => {
536
541
const boundsSpy = sinon . spy ( dialog . $ . overlay , 'setBounds' ) ;
537
542
content . style . width = `${ content . clientWidth * 4 } px` ;
538
543
const scrollbarHeight = container . offsetHeight - container . clientHeight ;
@@ -541,6 +546,7 @@ describe('draggable', () => {
541
546
x : containerBounds . left + containerBounds . width / 2 ,
542
547
y : containerBounds . top + containerBounds . height - scrollbarHeight / 2 ,
543
548
} ) ;
549
+ await nextRender ( ) ;
544
550
expect ( boundsSpy . called ) . to . equal ( ! scrollbarHeight ) ;
545
551
} ) ;
546
552
@@ -578,14 +584,6 @@ describe('draggable', () => {
578
584
expect ( Math . floor ( draggedBounds . height ) ) . to . be . eql ( Math . floor ( bounds . height ) ) ;
579
585
} ) ;
580
586
581
- it ( 'should not update overlay bounds with position: absolute' , ( ) => {
582
- const spy = sinon . spy ( dialog . $ . overlay , 'setBounds' ) ;
583
- dispatchMouseEvent ( content , 'mousedown' ) ;
584
- dialog . $ . overlay . $ . overlay . style . position = 'absolute' ;
585
- dispatchMouseEvent ( content , 'mousedown' ) ;
586
- expect ( spy . calledOnce ) . to . be . true ;
587
- } ) ;
588
-
589
587
it ( 'should not reset scroll position on dragstart' , async ( ) => {
590
588
dialog . modeless = true ;
591
589
button . style . marginBottom = '200px' ;
@@ -617,6 +615,22 @@ describe('draggable', () => {
617
615
expect ( detail . left ) . to . be . equal ( dialog . left ) ;
618
616
} ) ;
619
617
618
+ it ( 'should use correct coordinates in "dragged" event without moving the dialog during drag' , async ( ) => {
619
+ const overlayBounds = dialog . $ . overlay . getBounds ( ) ;
620
+ const onDragged = sinon . spy ( ) ;
621
+ dialog . addEventListener ( 'dragged' , onDragged ) ;
622
+
623
+ dispatchMouseEvent ( content , 'mousedown' ) ;
624
+ await nextRender ( ) ;
625
+ dispatchMouseEvent ( content , 'mouseup' ) ;
626
+ await nextRender ( ) ;
627
+
628
+ expect ( onDragged . calledOnce ) . to . be . true ;
629
+ const { detail } = onDragged . args [ 0 ] [ 0 ] ;
630
+ expect ( detail . top ) . to . be . equal ( overlayBounds . top ) ;
631
+ expect ( detail . left ) . to . be . equal ( overlayBounds . left ) ;
632
+ } ) ;
633
+
620
634
it ( 'should not set overlay max-width to none on drag' , async ( ) => {
621
635
drag ( container ) ;
622
636
await nextRender ( ) ;
0 commit comments