Browse Source

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

Falko Schindler 1 year ago
parent
commit
6e78db537c
1 changed files with 2 additions and 0 deletions
  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 = []
                 value = []
             elif not isinstance(value, list):
             elif not isinstance(value, list):
                 value = [value]
                 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)
         super().__init__(options=options, value=value, on_change=on_change, validation=validation)
         if label is not None:
         if label is not None:
             self._props['label'] = label
             self._props['label'] = label