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 #124 from ckeditor/t/123
Browse files Browse the repository at this point in the history
Fix: URL input value should not be `'undefined'` when no link is selected. Closes #123.
  • Loading branch information
Reinmar committed May 19, 2017
2 parents 1784eb6 + 38b0b1b commit 22893d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ export default class Link extends Plugin {
// unaltered) and re-opened it without changing the value of the link command (e.g. because they
// clicked the same link), they would see the old value instead of the actual value of the command.
// https://github.com/ckeditor/ckeditor5-link/issues/78
this.formView.urlInputView.inputView.element.value = command.value;
// https://github.com/ckeditor/ckeditor5-link/issues/123
this.formView.urlInputView.inputView.element.value = command.value || '';

this.listenTo( showViewDocument, 'render', () => {
const renderSelectedLink = this._getSelectedLinkElement();
Expand Down
12 changes: 11 additions & 1 deletion tests/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe( 'Link', () => {
} );

// https://github.com/ckeditor/ckeditor5-link/issues/78
it( 'should make sure the URL input in the #formView always stays in sync with the value of the command', () => {
it( 'should make sure the URL input in the #formView always stays in sync with the value of the command (selected link)', () => {
setModelData( editor.document, '<paragraph><$text linkHref="url">f[]oo</$text></paragraph>' );

// Mock some leftover value **in DOM**, e.g. after previous editing.
Expand All @@ -228,6 +228,16 @@ describe( 'Link', () => {
} );
} );

// https://github.com/ckeditor/ckeditor5-link/issues/123
it( 'should make sure the URL input in the #formView always stays in sync with the value of the command (no link selected)', () => {
setModelData( editor.document, '<paragraph>f[]oo</paragraph>' );

return linkFeature._showPanel()
.then( () => {
expect( formView.urlInputView.inputView.element.value ).to.equal( '' );
} );
} );

describe( 'when the document is rendering', () => {
it( 'should not duplicate #render listeners', () => {
const viewDocument = editor.editing.view;
Expand Down

0 comments on commit 22893d3

Please sign in to comment.