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 #489 from ckeditor/t/487
Browse files Browse the repository at this point in the history
Other: The `ContextualBalloon#add` method should accept the `withArrow` option. Closes #487.
  • Loading branch information
oleq authored Apr 19, 2019
2 parents e375a72 + 840e925 commit 0e7f670
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class ContextualBalloon extends Plugin {
* @param {module:ui/view~View} [data.view] Content of the balloon.
* @param {module:utils/dom/position~Options} [data.position] Positioning options.
* @param {String} [data.balloonClassName] Additional css class for {@link #view} added when given view is visible.
* @param {Boolean} [data.withArrow=true] Whether the balloon should be rendered with an arrow.
*/
add( data ) {
if ( this.hasView( data.view ) ) {
Expand Down Expand Up @@ -203,9 +204,11 @@ export default class ContextualBalloon extends Plugin {
* @param {Object} data Configuration.
* @param {module:ui/view~View} [data.view] View to show in the balloon.
* @param {String} [data.balloonClassName=''] Additional class name which will added to the {#_balloon} view.
* @param {Boolean} [data.withArrow=true] Whether the {@link #_balloon} view should be rendered with an arrow.
*/
_show( { view, balloonClassName = '' } ) {
_show( { view, balloonClassName = '', withArrow = true } ) {
this.view.class = balloonClassName;
this.view.withArrow = withArrow;

this.view.content.add( view );
this.view.pin( this._getBalloonPosition() );
Expand Down
41 changes: 41 additions & 0 deletions tests/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,47 @@ describe( 'ContextualBalloon', () => {

expect( balloon.view.class ).to.equal( 'bar' );
} );

it( 'should hide arrow if `withArrow` option is set to false', () => {
balloon.remove( viewA );
balloon.view.pin.resetHistory();

balloon.add( {
view: viewB,
position: {
target: 'foo'
},
withArrow: false
} );

expect( balloon.view.withArrow ).to.be.false;
} );

it( 'should show arrow if `withArrow` option was not set and previously shown view had hidden arrow', () => {
balloon.remove( viewA );
balloon.view.pin.resetHistory();

balloon.add( {
view: viewB,
position: {
target: 'foo'
},
withArrow: false
} );

expect( balloon.view.withArrow ).to.be.false;

balloon.remove( viewB );

balloon.add( {
view: viewB,
position: {
target: 'foo'
}
} );

expect( balloon.view.withArrow ).to.be.true;
} );
} );

describe( 'visibleView', () => {
Expand Down

0 comments on commit 0e7f670

Please sign in to comment.