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

Commit

Permalink
Merge pull request #406 from ckeditor/t/ckeditor5-table/28
Browse files Browse the repository at this point in the history
Other: Made the `ContextualBalloon` always use the position of the topmost view in the stack (see: ckeditor/ckeditor5-table#28). Closes ckeditor/ckeditor5#900.
  • Loading branch information
jodator authored Jun 8, 2018
2 parents 76a4d47 + eda46b4 commit a2ef073
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import BalloonPanelView from './balloonpanelview';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import first from '@ckeditor/ckeditor5-utils/src/first';

/**
* Provides the common contextual balloon panel for the editor.
Expand Down Expand Up @@ -213,14 +212,14 @@ export default class ContextualBalloon extends Plugin {
}

/**
* Returns position options of the first view in the stack.
* Returns position options of the last view in the stack.
* This keeps the balloon in the same position when view is changed.
*
* @private
* @returns {module:utils/dom/position~Options}
*/
_getBalloonPosition() {
let position = first( this._stack.values() ).position;
let position = Array.from( this._stack.values() ).pop().position;

// Use the default limiter if none has been specified.
if ( position && !position.limiter ) {
Expand Down
10 changes: 5 additions & 5 deletions tests/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ describe( 'ContextualBalloon', () => {
expect( balloon.view.content.get( 0 ) ).to.deep.equal( viewB );
} );

it( 'should keep balloon at the same position after adding next view', () => {
it( 'should use the position of the last view in the stack', () => {
balloon.add( {
view: viewB,
position: { target: 'other' }
Expand All @@ -272,7 +272,7 @@ describe( 'ContextualBalloon', () => {
} );

sinon.assert.calledWithMatch( balloon.view.pin.secondCall, {
target: 'fake',
target: 'other',
limiter: balloon.positionLimiter
} );
} );
Expand Down Expand Up @@ -399,7 +399,7 @@ describe( 'ContextualBalloon', () => {
} );

describe( 'updatePosition()', () => {
it( 'should attach balloon to the target using position option from the first view in the stack', () => {
it( 'should attach balloon to the target using position option from the last view in the stack', () => {
balloon.add( {
view: viewB,
position: {
Expand All @@ -413,7 +413,7 @@ describe( 'ContextualBalloon', () => {

expect( balloon.view.pin.calledOnce );
sinon.assert.calledWithMatch( balloon.view.pin.firstCall, {
target: 'fake',
target: 'other',
limiter: balloon.positionLimiter
} );
} );
Expand Down Expand Up @@ -444,7 +444,7 @@ describe( 'ContextualBalloon', () => {

expect( balloon.view.pin.calledOnce );
sinon.assert.calledWithMatch( balloon.view.pin.firstCall, {
target: 'fake',
target: 'new',
limiter: balloon.positionLimiter
} );

Expand Down

0 comments on commit a2ef073

Please sign in to comment.