|
|
@@ -378,22 +378,37 @@ describe( 'WidgetResize', () => {
|
|
|
expect( commitStub.callCount, 'call count' ).to.be.eql( 0 );
|
|
|
} );
|
|
|
|
|
|
+ // Note that ultimately width should be changed, but through a model converter, not with direct view changes (#6060).
|
|
|
it( 'restores the original view width after resize is done', () => {
|
|
|
- // Note that ultimately width should be changed, but through a model converter, not with direct view changes (#6060).
|
|
|
createResizer();
|
|
|
+
|
|
|
+ const usedHandle = 'bottom-right';
|
|
|
+ const domParts = getWidgetDomParts( editor, widget, usedHandle );
|
|
|
+ const finalPointerPosition = getHandleCenterPoint( domParts.widget, usedHandle ).moveBy( 40, 40 );
|
|
|
+
|
|
|
+ resizerMouseSimulator.dragTo( editor, domParts.resizeHandle, finalPointerPosition );
|
|
|
+
|
|
|
+ expect( widget.getStyle( 'width' ) ).to.equal( INITIAL_WIDGET_WIDTH );
|
|
|
+ } );
|
|
|
+
|
|
|
+ // Verify render count https://github.com/ckeditor/ckeditor5-widget/pull/122#issuecomment-617012777.
|
|
|
+ it( 'renders the final result in one step', () => {
|
|
|
const renderListener = sinon.stub();
|
|
|
+ const resizer = createResizer();
|
|
|
|
|
|
const usedHandle = 'bottom-right';
|
|
|
const domParts = getWidgetDomParts( editor, widget, usedHandle );
|
|
|
const finalPointerPosition = getHandleCenterPoint( domParts.widget, usedHandle ).moveBy( 40, 40 );
|
|
|
|
|
|
- editor.editing.view.on( 'render', renderListener );
|
|
|
+ // Start listening on render at the last stage, to exclude rendering caused by moving the mouse.
|
|
|
+ // Commit is triggered by mouse up and that's what interests us.
|
|
|
+ resizer.on( 'commit', () => {
|
|
|
+ editor.editing.view.on( 'render', renderListener );
|
|
|
+ }, { priority: 'highest' } );
|
|
|
|
|
|
resizerMouseSimulator.dragTo( editor, domParts.resizeHandle, finalPointerPosition );
|
|
|
|
|
|
- expect( widget.getStyle( 'width' ) ).to.equal( INITIAL_WIDGET_WIDTH );
|
|
|
- // Verify render count https://github.com/ckeditor/ckeditor5-widget/pull/122#issuecomment-617012777.
|
|
|
- expect( renderListener.callCount ).to.be.equal( 3 );
|
|
|
+ expect( renderListener.callCount ).to.be.equal( 1 );
|
|
|
} );
|
|
|
|
|
|
it( 'returns proper value when resize host is different from widget wrapper', () => {
|