Explorar el Código

Fix value when multiple elements are selected (#571)

If you have two elements selected that have a different value (eg: a green line and a red line), the value of the color picker should be undefined, not the default value.
Christopher Chedeau hace 5 años
padre
commit
ed42672fd3
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      src/actions/actionProperties.tsx

+ 3 - 2
src/actions/actionProperties.tsx

@@ -27,8 +27,9 @@ const getFormValue = function<T>(
 ): T | null {
   return (
     (editingElement && getAttribute(editingElement)) ??
-    getCommonAttributeOfSelectedElements(elements, getAttribute) ??
-    defaultValue ??
+    (elements.some(element => element.isSelected)
+      ? getCommonAttributeOfSelectedElements(elements, getAttribute)
+      : defaultValue) ??
     null
   );
 };