Skip to content

Commit

Permalink
Merge pull request #17579 from ckeditor/ck/epic/17230-fix-focus-toolb…
Browse files Browse the repository at this point in the history
…ar-button

Internal (link): Open link form on top of the link toolbar if user clicked toolbar button on selected link. Focus no longer stays in link toolbar.
  • Loading branch information
Mati365 authored Dec 3, 2024
2 parents 0cfd778 + 97f0eeb commit 99d6e76
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/ckeditor5-link/src/linkui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,15 @@ export default class LinkUI extends Plugin {
view.bind( 'isOn' ).to( command, 'value', value => !!value );

// Show the panel on button click.
this.listenTo<ButtonExecuteEvent>( view, 'execute', () => this._showUI( true ) );
this.listenTo<ButtonExecuteEvent>( view, 'execute', () => {
this._showUI( true );

// Open the form view on-top of the toolbar view if it's already visible.
// It should be visible every time the link is selected.
if ( this._getSelectedLinkElement() ) {
this._addFormView();
}
} );

return view;
}
Expand Down
8 changes: 8 additions & 0 deletions packages/ckeditor5-link/tests/linkui.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ describe( 'LinkUI', () => {

expect( linkUIFeature.formView.backButtonView.isVisible ).to.be.false;
} );

it( 'should open on-top of the toolbar if the link is selected', () => {
setModelData( editor.model, '<paragraph><$text linkHref="url">f[]oo</$text></paragraph>' );

linkButton.fire( 'execute' );

expect( balloon.visibleView ).to.equal( linkUIFeature.formView );
} );
}

describe( 'the "linkPreview" toolbar button', () => {
Expand Down

0 comments on commit 99d6e76

Please sign in to comment.