From b6d69e0f10c853761f8f01863f99e18dc32f7647 Mon Sep 17 00:00:00 2001
From: Gregoo <versatile.mailbox@gmail.com>
Date: Tue, 4 Feb 2025 23:03:56 +0100
Subject: [PATCH] Revert the checked state of a checkbox if an error occured

---
 CHANGELOG.md              | 3 +++
 static/scripts/changer.js | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6f89a8..9a6ba43 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,9 @@
 
 ### Code
 
+- Changer
+    - Revert the checked state of a checkbox if an error occured
+
 - Form
     - Migrate missing input fields to BrickChanger
 
diff --git a/static/scripts/changer.js b/static/scripts/changer.js
index ffa41ac..a32af76 100644
--- a/static/scripts/changer.js
+++ b/static/scripts/changer.js
@@ -174,6 +174,11 @@ class BrickChanger {
             console.log(error.message);
 
             this.status_error(error.message);
+
+            // Reverse the checked state
+            if (this.html_type == "checkbox") {
+                this.html_element.checked = !this.html_element.checked;
+            }
         }
     }
 }