Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
BalloonPanelView#pin should show the balloon and BalloonPanelView#unp…
Browse files Browse the repository at this point in the history
…in should hide it.
  • Loading branch information
oleq committed Apr 10, 2017
1 parent 6f93201 commit 6fd3276
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
7 changes: 3 additions & 4 deletions src/panel/balloon/balloonpanelview.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,7 @@ export default class BalloonPanelView extends View {
}
};

// If the panel is already visible, start pinning immediately.
if ( this.isVisible ) {
this._startPinning( options );
}
this._startPinning( options );

// Control the state of the listeners depending on whether the panel is visible
// or not.
Expand All @@ -234,6 +231,8 @@ export default class BalloonPanelView extends View {
this.stopListening( this, 'change:isVisible', this._pinWhenIsVisibleCallback );

this._pinWhenIsVisibleCallback = null;

this.hide();
}
}

Expand Down
1 change: 0 additions & 1 deletion tests/manual/tickets/170/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ ClassicEditor.create( document.querySelector( '#editor-stick' ), {
editor.ui.view.element.querySelector( '.ck-editor__editable' ).scrollTop = 360;

panel.init().then( () => {
panel.show();
panel.pin( {
target: editor.ui.view.element.querySelector( '.ck-editor__editable p strong' ),
limiter: editor.ui.view.editableElement
Expand Down
19 changes: 10 additions & 9 deletions tests/panel/balloon/balloonpanelview.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,26 +446,27 @@ describe( 'BalloonPanelView', () => {
} );

describe( 'pin()', () => {
it( 'should not show the balloon', () => {
const showSpy = sinon.spy( view, 'show' );
it( 'should show the balloon', () => {
const spy = sinon.spy( view, 'show' );

view.hide();

view.pin( { target, limiter } );
sinon.assert.notCalled( showSpy );
sinon.assert.calledOnce( spy );
} );

it( 'should start pinning when the balloon is visible', () => {
view.hide();
view.pin( { target, limiter } );
sinon.assert.calledOnce( attachToSpy );

view.hide();
targetParent.dispatchEvent( new Event( 'scroll' ) );

view.show();
sinon.assert.calledTwice( attachToSpy );

targetParent.dispatchEvent( new Event( 'scroll' ) );

sinon.assert.calledTwice( attachToSpy );
sinon.assert.calledThrice( attachToSpy );
} );

it( 'should stop pinning when the balloon becomes invisible', () => {
Expand Down Expand Up @@ -603,13 +604,13 @@ describe( 'BalloonPanelView', () => {
} );

describe( 'unpin()', () => {
it( 'should not hide the balloon if pinned', () => {
const hideSpy = sinon.spy( view, 'hide' );
it( 'should hide the balloon if pinned', () => {
const spy = sinon.spy( view, 'hide' );

view.pin( { target, limiter } );
view.unpin();

sinon.assert.notCalled( hideSpy );
sinon.assert.calledOnce( spy );
} );

it( 'should stop attaching', () => {
Expand Down

0 comments on commit 6fd3276

Please sign in to comment.