From ac2883969bdcf73ddcebb494292cd36ccec08a3a Mon Sep 17 00:00:00 2001
From: Sonja Happ <sonja.happ@eonerc.rwth-aachen.de>
Date: Wed, 5 May 2021 14:14:12 +0200
Subject: [PATCH] fix a bug with the checkbox control in widget edit menus

---
 .../edit-widget-checkbox-control.js           | 20 +++++++++----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/widget/edit-widget/edit-widget-checkbox-control.js b/src/widget/edit-widget/edit-widget-checkbox-control.js
index 6dd8ce0..9ea51c4 100644
--- a/src/widget/edit-widget/edit-widget-checkbox-control.js
+++ b/src/widget/edit-widget/edit-widget-checkbox-control.js
@@ -21,21 +21,19 @@ import { Form } from 'react-bootstrap';
 class EditWidgetCheckboxControl extends React.Component {
   constructor(props) {
     super(props);
+  }
 
-    let parts = this.props.controlId.split('.');
-    let isCustomProperty = true;
-    if (parts.length ===1){
-      isCustomProperty = false;
-    }
-
+  static getDerivedStateFromProps(props, state) {
+    let parts = props.controlId.split('.');
     let isChecked;
-    if (isCustomProperty){
-      isChecked = this.props.widget[parts[0]][parts[1]]
-    } else{
-      isChecked = this.props.widget[this.props.controlId]
+
+    if (parts.length ===1){
+      isChecked = props.widget[props.controlId]
+    } else {
+      isChecked = props.widget[parts[0]][parts[1]]
     }
 
-    this.state = {
+    return {
       isChecked
     };
   }