Browse Source

improve `set_options` method for choice elements (fixes #2682)

Falko Schindler 1 year ago
parent
commit
25e0695257
1 changed files with 4 additions and 3 deletions
  1. 4 3
      nicegui/elements/choice_element.py

+ 4 - 3
nicegui/elements/choice_element.py

@@ -34,13 +34,14 @@ class ChoiceElement(ValueElement):
         self._update_options()
         super().update()
 
-    def set_options(self, options: Union[List, Dict], *, value: Any = None) -> None:
+    def set_options(self, options: Union[List, Dict], *, value: Any = ...) -> None:
         """Set the options of this choice element.
 
         :param options: The new options.
         :param value: The new value. If not given, the current value is kept.
         """
         self.options = options
-        if value is not None:
-            self.value = value
         self.update()
+        if value is not ...:
+            self.value = value
+            self.update()