Skip to content

Commit 7e4ec9f

Browse files
authored
Merge pull request #1501 from georgel-pop-lr/1500-paragraphAlign
fix: Prevent activeCommand in button-paragraph-align.jsx to be undefined (#1500)
2 parents ecdadc4 + 0dbb929 commit 7e4ec9f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/buttons/button-paragraph-align.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ class ButtonParagraphAlign extends React.Component {
3030
render() {
3131
let buttonCommandsList;
3232
let buttonCommandsListId;
33+
const getCommands = this._getCommands();
3334

3435
if (this.props.expanded) {
3536
buttonCommandsListId = ButtonParagraphAlign.key + 'List';
3637
buttonCommandsList = (
3738
<ButtonCommandsList
38-
commands={this._getCommands()}
39+
commands={getCommands}
3940
inlineIcons={false}
4041
listId={buttonCommandsListId}
4142
onDismiss={this.props.toggleDropdown}
@@ -45,14 +46,16 @@ class ButtonParagraphAlign extends React.Component {
4546

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

48-
const activeCommand = this._getCommands()
49+
let activeCommand = getCommands
4950
.filter(alignment => {
5051
const command = editor.getCommand(alignment.command);
5152

5253
return command ? command.state === CKEDITOR.TRISTATE_ON : false;
5354
})
5455
.pop();
5556

57+
activeCommand = activeCommand ? activeCommand : getCommands[0];
58+
5659
const iconClassName = activeCommand.icon;
5760

5861
return (

0 commit comments

Comments
 (0)