Explorar el Código

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

Falko Schindler hace 1 año
padre
commit
6e78db537c
Se han modificado 1 ficheros con 2 adiciones y 0 borrados
  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