Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added default value to useComputedState in the CKEDITOR config object #4940

Conversation

shabab477
Copy link

Issue #4918

What is the purpose of this pull request?

Does your PR contain necessary tests?

All patches that change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.

This PR contains

  • Unit tests
  • Manual tests

Did you follow the CKEditor 4 code style guide?

Your code should follow the guidelines from the CKEditor 4 code style guide which helps keep the entire codebase consistent.

  • PR is consistent with the code style guide

What is the proposed changelog entry for this pull request?

Skipped

What changes did you make?

Added default config value for useComputedState

Which issues does your PR resolve?

Closes #4918.

@Comandeer Comandeer self-requested a review November 3, 2021 12:23
Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @shabab477! Thanks for your contribution.

The change looks good. However, we require that every change be accompanied by the test. Could I ask you to add a test to /tests/config directory? The test can be simple, e.g. creating the editor and then checking its editor.config.useComputedState value.

It'd be also good to remove the logic connected to treating undefined config.useComputedState variable the same way as the one set to true (see the issue's description for more info). Could you add it as a part of this PR?

@shabab477
Copy link
Author

Alright 👍

@shabab477 shabab477 force-pushed the bugfix/added-default-value-config-use-computed-state branch from 02ef654 to f10519e Compare November 5, 2021 05:38
Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your fixes!

The test looks good. Could I ask you to add a similar one also to tests/core/config/themed_ui.js?

There are also several other places in plugins where the trick similar to the one with undefined is used, e.g.

var useComputedState = ( 'useComputedState' in editor.config ) ? editor.config.useComputedState : 1;
. Could I ask you to also fix them?

core/config.js Outdated
Comment on lines 382 to 385
*
* @since 3.4.0
* @cfg {Boolean} [useComputedState=true]
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation here seems to be incorrect:

Suggested change
*
* @since 3.4.0
* @cfg {Boolean} [useComputedState=true]
*/
*
* @since 3.4.0
* @cfg {Boolean} [useComputedState=true]
*/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -22,6 +22,10 @@ bender.test( {
} );
},

test_startup_computed_state_value: function() {
assert.isTrue( this.editor.config.useComputedState === true, 'config.useComputedState should return true as default' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to compare variable's value to true, asserting its value is enough in this case:

Suggested change
assert.isTrue( this.editor.config.useComputedState === true, 'config.useComputedState should return true as default' );
assert.isTrue( this.editor.config.useComputedState, 'config.useComputedState should return true as default' );

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jacekbogdanski jacekbogdanski changed the base branch from major to next November 18, 2021 07:21
@jacekbogdanski jacekbogdanski changed the base branch from next to master November 18, 2021 07:21
@shabab477 shabab477 force-pushed the bugfix/added-default-value-config-use-computed-state branch from f10519e to 478711b Compare November 19, 2021 08:43
@shabab477
Copy link
Author

Fixed usages of useComputedState workarounds in the code for plugins:

  • justify
  • list
  • bidi

@Comandeer Comandeer self-requested a review November 24, 2021 10:42
@Comandeer Comandeer force-pushed the bugfix/added-default-value-config-use-computed-state branch from 478711b to d7507d5 Compare November 24, 2021 13:57
Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks once again for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default value for useComputedState is undefined but treated as true value.
2 participants