Skip to content

Commit

Permalink
#578 - Added extra checks for term selection
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Jun 12, 2020
1 parent 01af3c9 commit 5be8a5d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/controls/taxonomyPicker/Term.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export default class Term extends React.Component<ITermProps, ITermState> {
return styles.termEnabled;
}

private termActionCallback = (updateAction: UpdateAction): void => {
if (updateAction == null) {
private termActionCallback = (updateAction: UpdateAction | null): void => {
if (!updateAction) {
return;
}

Expand All @@ -88,10 +88,13 @@ export default class Term extends React.Component<ITermProps, ITermState> {
disabled: updateAction.value as boolean
});
} else if (updateAction.updateActionType === UpdateType.selectTerm) {
this.setState({
selected: updateAction.value as boolean
});
this.props.changedCallback(this.props.term, updateAction.value as boolean);
// Only select the term when not disabled or hidden
if (!this.state.disabled && !this.state.hidden) {
this.setState({
selected: updateAction.value as boolean
});
this.props.changedCallback(this.props.term, updateAction.value as boolean);
}
} else {
this.props.updateTaxonomyTree();
}
Expand Down
4 changes: 2 additions & 2 deletions src/controls/taxonomyPicker/termActions/ITermsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ITermActionsControlProps {
/**
* Callback after execution term action.
*/
termActionCallback: (updateAction: UpdateAction) => void;
termActionCallback: (updateAction: UpdateAction | null) => void;
}

export interface ITermActionsControlState {
Expand All @@ -40,7 +40,7 @@ export interface IConcreteTermActionProps {
term: ITerm;
displayStyle: TermActionsDisplayStyle;
spTermService: SPTermStorePickerService;
termActionCallback: (updateAction: UpdateAction) => void;
termActionCallback: (updateAction: UpdateAction | null) => void;
}

/**
Expand Down

0 comments on commit 5be8a5d

Please sign in to comment.