瀏覽代碼

prevent value and options from sharing the same reference (fixes #3014)

Falko Schindler 1 年之前
父節點
當前提交
6e78db537c
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      nicegui/elements/select.py

+ 2 - 0
nicegui/elements/select.py

@@ -58,6 +58,8 @@ class Select(ValidationElement, ChoiceElement, DisableableElement, component='se
                 value = []
             elif not isinstance(value, list):
                 value = [value]
+            else:
+                value = value[:]  # NOTE: avoid modifying the original list which could be the list of options (#3014)
         super().__init__(options=options, value=value, on_change=on_change, validation=validation)
         if label is not None:
             self._props['label'] = label