Skip to content

Commit

Permalink
Merge pull request #9 from sitegeist/bugfix/emptyTagSelection
Browse files Browse the repository at this point in the history
BUGFIX: Handle empty reference lists in TaxonomyEditor
  • Loading branch information
mficzel authored Jun 26, 2019
2 parents ec44772 + 16fbb10 commit b0bc539
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
11 changes: 3 additions & 8 deletions Resources/Private/Scripts/TaxonomyEditor/src/TaxonomyEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export default class TaxonomyEditor extends PureComponent {
}

handleToggleTaxonomyInSecondaryInspector = taxonomyIdentifier => {
const {value, commit} = this.props;
const value = Array.isArray(this.props.value) ? this.props.value : [];
const {commit} = this.props;

if (value.includes(taxonomyIdentifier)) {
commit(value.filter(item => item !== taxonomyIdentifier));
Expand Down Expand Up @@ -88,12 +89,6 @@ export default class TaxonomyEditor extends PureComponent {
}
});


handleSort = ({oldIndex, newIndex}) => {
const {value, commit} = this.props;
commit(arrayMove(value, oldIndex, newIndex));
}

handleCommit = value => {
const {commit} = this.props;

Expand Down Expand Up @@ -124,7 +119,7 @@ export default class TaxonomyEditor extends PureComponent {
</Button>
{secondaryInspectorPortal ? createPortal(
<TaxonomyTreeSelect
value={value}
value={Array.isArray(value) ? value : []}
identifier={identifier}
options={options}
onToggleTaxonomy={this.handleToggleTaxonomyInSecondaryInspector}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import styles from './TaxonomyTreeSelect.css';

@connect((state, {identifier}) => {
const contextForNodeLinking = selectors.UI.NodeLinking.contextForNodeLinking(state);
const sourceValue = $get(['properties', identifier], selectors.CR.Nodes.focusedSelector(state));
const unsanitizedSourceValue = $get(['properties', identifier], selectors.CR.Nodes.focusedSelector(state));
const sourceValue = Array.isArray(unsanitizedSourceValue) ? unsanitizedSourceValue : [];

return {contextForNodeLinking, sourceValue};
})
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/TaxonomyEditor/Plugin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/TaxonomyEditor/Plugin.js.map

Large diffs are not rendered by default.

0 comments on commit b0bc539

Please sign in to comment.