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

Commit a2ef073

Browse files
authored
Merge pull request #406 from ckeditor/t/ckeditor5-table/28
Other: Made the `ContextualBalloon` always use the position of the topmost view in the stack (see: ckeditor/ckeditor5-table#28). Closes ckeditor/ckeditor5#900.
2 parents 76a4d47 + eda46b4 commit a2ef073

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/panel/balloon/contextualballoon.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
1111
import BalloonPanelView from './balloonpanelview';
1212
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
13-
import first from '@ckeditor/ckeditor5-utils/src/first';
1413

1514
/**
1615
* Provides the common contextual balloon panel for the editor.
@@ -213,14 +212,14 @@ export default class ContextualBalloon extends Plugin {
213212
}
214213

215214
/**
216-
* Returns position options of the first view in the stack.
215+
* Returns position options of the last view in the stack.
217216
* This keeps the balloon in the same position when view is changed.
218217
*
219218
* @private
220219
* @returns {module:utils/dom/position~Options}
221220
*/
222221
_getBalloonPosition() {
223-
let position = first( this._stack.values() ).position;
222+
let position = Array.from( this._stack.values() ).pop().position;
224223

225224
// Use the default limiter if none has been specified.
226225
if ( position && !position.limiter ) {

tests/panel/balloon/contextualballoon.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ describe( 'ContextualBalloon', () => {
258258
expect( balloon.view.content.get( 0 ) ).to.deep.equal( viewB );
259259
} );
260260

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

274274
sinon.assert.calledWithMatch( balloon.view.pin.secondCall, {
275-
target: 'fake',
275+
target: 'other',
276276
limiter: balloon.positionLimiter
277277
} );
278278
} );
@@ -399,7 +399,7 @@ describe( 'ContextualBalloon', () => {
399399
} );
400400

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

414414
expect( balloon.view.pin.calledOnce );
415415
sinon.assert.calledWithMatch( balloon.view.pin.firstCall, {
416-
target: 'fake',
416+
target: 'other',
417417
limiter: balloon.positionLimiter
418418
} );
419419
} );
@@ -444,7 +444,7 @@ describe( 'ContextualBalloon', () => {
444444

445445
expect( balloon.view.pin.calledOnce );
446446
sinon.assert.calledWithMatch( balloon.view.pin.firstCall, {
447-
target: 'fake',
447+
target: 'new',
448448
limiter: balloon.positionLimiter
449449
} );
450450

0 commit comments

Comments
 (0)