Skip to content

Commit

Permalink
Merge branch 'master' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
jacekbogdanski committed Sep 21, 2021
2 parents cf9364b + b0acce2 commit b14851c
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Fixed Issues:
* [#4790](https://github.com/ckeditor/ckeditor4/issues/4790): Fixed: Printing page is invoked before the printed page is fully loaded.
* [#3876](https://github.com/ckeditor/ckeditor4/issues/3876): Fixed: [Print](https://ckeditor.com/cke4/addon/print) plugin incorrectly prints links and images.
* [#4444](https://github.com/ckeditor/ckeditor4/issues/4444): [Firefox] Fixed: Print preview is incorrectly loaded from CDN.
* [#4888](https://github.com/ckeditor/ckeditor4/issues/4888): Fixed: [`CKEDITOR.dialog#setState()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog.html#method-setState) method throws error when there is no "Ok" button in the dialog.

API Changes:

Expand Down
8 changes: 6 additions & 2 deletions plugins/dialog/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1535,12 +1535,16 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
// Finally, show the spinner.
this.parts.spinner.show();

this.getButton( 'ok' ).disable();
if ( this.getButton( 'ok' ) ) {
this.getButton( 'ok' ).disable();
}
} else if ( state == CKEDITOR.DIALOG_STATE_IDLE ) {
// Hide the spinner. But don't do anything if there is no spinner yet.
this.parts.spinner && this.parts.spinner.hide();

this.getButton( 'ok' ).enable();
if ( this.getButton( 'ok' ) ) {
this.getButton( 'ok' ).enable();
}
}

this.fire( 'state', state );
Expand Down
3 changes: 2 additions & 1 deletion tests/core/dom/element/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,8 @@ bender.test( appendDomObjectTests(
expectedWidth;

function round( num ) {
return Math.round( num * 100 ) / 100;
// Decrease precision of calculations (#3188).
return Math.floor( num * 100 ) / 100;
}

doc.getBody().append( elem );
Expand Down
45 changes: 45 additions & 0 deletions tests/plugins/dialog/manual/setstatenook.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<div id="editor">
<p>Somebody once told me the world is gonna roll me…</p>
</div>

<button id="press">Open Dialog</button>
<script>
( function() {
if ( bender.tools.env.mobile ) {
return bender.ignore();
}

var editor = CKEDITOR.replace( 'editor' );

CKEDITOR.once( 'instanceLoaded', function() {
CKEDITOR.dialog.add( 'testDialog', function() {
return {
title: 'Test dialog',
contents: [
{
id: 'tab1',
label: 'Tab one',
elements: [
{
type: 'html',
id: 'field11',
html: 'foo'
}
]
}
],
buttons: [],
onShow: function() {
this.setState( CKEDITOR.DIALOG_STATE_BUSY );
}
}
} );

editor.addCommand( 'testDialog', new CKEDITOR.dialogCommand( 'testDialog' ) );
} );

CKEDITOR.document.getById( 'press' ).on( 'click', function() {
editor.execCommand( 'testDialog' );
} );
} )();
</script>
13 changes: 13 additions & 0 deletions tests/plugins/dialog/manual/setstatenook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@bender-tags: 4.16.3, bug, 4888
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, link, image

1. Open the console.
2. Press "Open dialog" button.

**Expected** There is a spinner in the dialog's title bar and no errors in the console.

**Unexpected** There is no spinner in the dialog's title bar or some errors in the console.
3. Close the dialog

**Expected** No new errors appear in the console.
57 changes: 57 additions & 0 deletions tests/plugins/dialog/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,63 @@
wait();
},

// (#4888)
'test dialog setState does not throw when dialog has no Ok button': function() {
var editor = this.editor,
errorOccured = false;

CKEDITOR.dialog.add( 'testDialogSetStateNoOk', function() {
return {
title: 'Test Dialog setState No Ok',
contents: [
{
id: 'tab1',
label: 'Test 1',
elements: [
{
type: 'text',
id: 'foo',
label: 'foo',
requiredContent: 'p'
}
]
}
],
buttons: []
};
} );

editor.addCommand( 'testDialogSetStateNoOk', new CKEDITOR.dialogCommand( 'testDialogSetStateNoOk' ) );

editor.once( 'dialogShow', function( evt ) {
var dialog = evt.data;

resume( function() {
try {
dialog.setState( CKEDITOR.DIALOG_STATE_BUSY );
} catch ( err ) {
errorOccured = true;
}

assert.areSame( CKEDITOR.DIALOG_STATE_BUSY, dialog.state, 'Correct dialog state – BUSY' );

// These tries are separate to catch issues with setting and unsetting busy state.
try {
dialog.setState( CKEDITOR.DIALOG_STATE_IDLE );
} catch ( err ) {
errorOccured = true;
}

assert.areSame( CKEDITOR.DIALOG_STATE_IDLE, dialog.state, 'Correct dialog state – IDLE' );
assert.isFalse( errorOccured, 'No error occured' );
} );
} );

editor.execCommand( 'testDialogSetStateNoOk' );

wait();
},

// #830
'test dialog opens tab defined in tabId as default': function() {
var editor = this.editor;
Expand Down
8 changes: 8 additions & 0 deletions tests/plugins/widget/nestededitables.js
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,10 @@
},

'test focusing editor when focusing nested editable': function() {
if ( CKEDITOR.env.ie ) {
assert.ignore();
}

var editor = this.editor;

editor.widgets.add( 'testfocus1', {
Expand Down Expand Up @@ -1118,6 +1122,10 @@
},

'test subsequent nested editable focus causes selectionChange': function() {
if ( CKEDITOR.env.ie && CKEDITOR.env.version === 11 ) {
assert.ignore();
}

var editor = this.editor,
editorBot = this.editorBot;

Expand Down

0 comments on commit b14851c

Please sign in to comment.