This commit is contained in:
Brian McGee
2025-07-31 16:33:13 +01:00
parent fbcfa4c12e
commit a079fb247d
2 changed files with 6 additions and 5 deletions

View File

@@ -75,16 +75,17 @@ export const MachineTags = (props: MachineTagsProps) => {
sortedAndUniqueOptions([...staticOptions, ...defaultValue]),
);
const _setSelectedOptions = (options: MachineTag[] | null) => {
console.log("onChange called", options)
if (options === null) setSelectedOptions([...staticOptions]);
setSelectedOptions(
sortedOptions(uniqueOptions([...staticOptions, ...(options || [])])),
sortedAndUniqueOptions([...staticOptions, ...(options || [])])
);
};
const addSelectedOption = (option: MachineTag) => {
console.log("Adding option", option)
// ensure the new selected option exists in the list of available options
setAvailableOptions(sortedAndUniqueOptions([...availableOptions(), option]));

View File

@@ -22,7 +22,7 @@ const profiles = {
lastName: "Burgundy",
bio: "It's actually an optical illusion, it's the pattern on the pants.",
shareProfile: true,
tags: ["All", "Home Server", "Backup", "Random"],
tags: ["all", "home Server", "backup", "random"],
},
};
@@ -127,8 +127,8 @@ export const Default: Story = {
tags: v.pipe(v.array(v.string()), v.nonEmpty()),
})}
initialValues={profiles.ron}
onSubmit={async () => {
console.log("saving tags");
onSubmit={async (values) => {
console.log("saving tags", values);
}}
>
{({ editing, Field }) => (