Skip to content

Commit

Permalink
Merge pull request #1501 from georgel-pop-lr/1500-paragraphAlign
Browse files Browse the repository at this point in the history
 fix: Prevent activeCommand in button-paragraph-align.jsx to be undefined (#1500)
  • Loading branch information
diegonvs authored Sep 14, 2021
2 parents ecdadc4 + 0dbb929 commit 7e4ec9f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/buttons/button-paragraph-align.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ class ButtonParagraphAlign extends React.Component {
render() {
let buttonCommandsList;
let buttonCommandsListId;
const getCommands = this._getCommands();

if (this.props.expanded) {
buttonCommandsListId = ButtonParagraphAlign.key + 'List';
buttonCommandsList = (
<ButtonCommandsList
commands={this._getCommands()}
commands={getCommands}
inlineIcons={false}
listId={buttonCommandsListId}
onDismiss={this.props.toggleDropdown}
Expand All @@ -45,14 +46,16 @@ class ButtonParagraphAlign extends React.Component {

const editor = this.context.editor.get('nativeEditor');

const activeCommand = this._getCommands()
let activeCommand = getCommands
.filter(alignment => {
const command = editor.getCommand(alignment.command);

return command ? command.state === CKEDITOR.TRISTATE_ON : false;
})
.pop();

activeCommand = activeCommand ? activeCommand : getCommands[0];

const iconClassName = activeCommand.icon;

return (
Expand Down

0 comments on commit 7e4ec9f

Please sign in to comment.