From 245ab840baf1926ef2c03a8965fce85012887d92 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Tue, 16 May 2023 01:23:44 -0300
Subject: one form left

---
 .../exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx')

diff --git a/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx b/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx
index 05733fe19..dd85453e5 100644
--- a/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx
+++ b/packages/exchange-backoffice-ui/src/handlers/InputSelectMultiple.tsx
@@ -1,5 +1,5 @@
 import { Fragment, VNode, h } from "preact";
-import { Choice } from "./InputChoice.js";
+import { Choice } from "./InputChoiceStacked.js";
 import { LabelWithTooltipMaybeRequired, UIFormProps } from "./InputLine.js";
 import { useField } from "./useField.js";
 import { useState } from "preact/hooks";
@@ -8,9 +8,10 @@ export function InputSelectMultiple(
   props: {
     choices: Choice[];
     unique?: boolean;
+    max?: number;
   } & UIFormProps<Array<string>>,
 ): VNode {
-  const { name, label, choices, placeholder, tooltip, required, unique } =
+  const { name, label, choices, placeholder, tooltip, required, unique, max } =
     props;
   const { value, onChange } = useField<{ [s: string]: Array<string> }>(name);
 
@@ -113,6 +114,9 @@ export function InputSelectMultiple(
                     if (unique && list.indexOf(v.value) !== -1) {
                       return;
                     }
+                    if (max !== undefined && list.length >= max) {
+                      return;
+                    }
                     const newValue = [...list];
                     newValue.splice(0, 0, v.value);
                     onChange(newValue);
-- 
cgit v1.2.3

