diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx')
-rw-r--r-- | server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx index 0b07f5b597d..dcdc5b733dd 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx @@ -104,14 +104,19 @@ export default class RuleDetails extends React.PureComponent<Props, State> { handleTagsChange = (tags: string[]) => { // optimistic update const oldTags = this.state.ruleDetails && this.state.ruleDetails.tags; - this.setState(state => ({ ruleDetails: { ...state.ruleDetails, tags } })); + this.setState( + state => (state.ruleDetails ? { ruleDetails: { ...state.ruleDetails, tags } } : null) + ); updateRule({ key: this.props.ruleKey, organization: this.props.organization, tags: tags.join() }).catch(() => { if (this.mounted) { - this.setState(state => ({ ruleDetails: { ...state.ruleDetails, tags: oldTags } })); + this.setState( + state => + state.ruleDetails ? { ruleDetails: { ...state.ruleDetails, tags: oldTags } } : null + ); } }); }; |