Skip to content

Commit

Permalink
Merge pull request #257 from ckeditor/i/6530
Browse files Browse the repository at this point in the history
Internal: Get the value of the link URL from the DOM input element instead of the `LinkFormView#urlInputView#fieldView#value` on submit. Closes #6530.
  • Loading branch information
oleq authored Apr 3, 2020
2 parents 47b791e + 6aab6e6 commit c6fd599
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/ckeditor5-link/src/linkui.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class LinkUI extends Plugin {

// Execute link command after clicking the "Save" button.
this.listenTo( formView, 'submit', () => {
editor.execute( 'link', formView.urlInputView.fieldView.value, formView.getDecoratorSwitchesState() );
editor.execute( 'link', formView.urlInputView.fieldView.element.value, formView.getDecoratorSwitchesState() );
this._closeFormView();
} );

Expand Down Expand Up @@ -307,7 +307,7 @@ export default class LinkUI extends Plugin {
// 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
// https://github.com/ckeditor/ckeditor5-link/issues/123
this.formView.urlInputView.fieldView.value = linkCommand.value || '';
this.formView.urlInputView.fieldView.element.value = linkCommand.value || '';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/ckeditor5-link/tests/linkui.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,20 @@ describe( 'LinkUI', () => {
setModelData( editor.model, '<paragraph><$text linkHref="url">f[]oo</$text></paragraph>' );

// Mock some leftover value **in DOM**, e.g. after previous editing.
formView.urlInputView.fieldView.value = 'leftover';
formView.urlInputView.fieldView.element.value = 'leftover';

linkUIFeature._showUI();
actionsView.fire( 'edit' );

expect( formView.urlInputView.fieldView.value ).to.equal( 'url' );
expect( formView.urlInputView.fieldView.element.value ).to.equal( 'url' );
} );

// 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.model, '<paragraph>f[]oo</paragraph>' );

linkUIFeature._showUI();
expect( formView.urlInputView.fieldView.value ).to.equal( '' );
expect( formView.urlInputView.fieldView.element.value ).to.equal( '' );
} );

it( 'should optionally force `main` stack to be visible', () => {
Expand Down

0 comments on commit c6fd599

Please sign in to comment.