浏览代码

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

Falko Schindler 1 年之前
父节点
当前提交
25e0695257
共有 1 个文件被更改,包括 4 次插入3 次删除
  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()