⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
feat: multiselect for customfield (#1735)
LAZIC Erwane55bdc4627f1
diff --git a/apps/api/src/custom-field/controllers/create-custom-field.ts b/apps/api/src/custom-field/controllers/create-custom-field.tsindex 6010a20f9..c0ea79d4c 100644--- a/apps/api/src/custom-field/controllers/create-custom-field.ts+++ b/apps/api/src/custom-field/controllers/create-custom-field.ts@@ -8,7 +8,10 @@ import {taskTable,} from "../../database/schema";-import { validateCustomFieldValue } from "../../task/validate-task-fields";+import {+ isCustomFieldValueEmpty,+ validateCustomFieldValue,+} from "../../task/validate-task-fields";async function createCustomField(projectId: string,@@ -18,6 +21,9 @@ async function createCustomField(defaultValue?: string,options?: string[],) {+ if (!name.trim())+ throw new HTTPException(400, { message: "Name cannot be empty" });+const [project] = await db.select({ id: projectTable.id }).from(projectTable)@@ -83,12 +89,48 @@ async function createCustomField(}}- if (type === "dropdown" && (!options || options.length === 0)) {+ if (type === "dropdown" && (!options || options.length < 1)) {throw new HTTPException(400, {message: "Dropdown fields must have at least one option",});}+ if (type === "multiselect") {+ const normalizedOptions = Array.from(+ new Set(+ (options ?? [])+ .map((opt) => opt.trim())+ .filter((opt) => opt.length > 0),+ ),+ );++ if (normalizedOptions.length < 2) {+ throw new HTTPException(400, {+ message: "Multiselect fields must have at least 2 options",+ });+ }+ }++ if (type === "multiselect" && defaultValue != null) {+ const empty = isCustomFieldValueEmpty(defaultValue, "multiselect");+ if (required && empty) {+ throw new HTTPException(400, {+ message: "Required fields must have a default value",+ });+ }+ if (!empty) {+ const error = validateCustomFieldValue(+ defaultValue,+ "multiselect",+ name,+ options,+ );+ if (error) {+ throw new HTTPException(400, { message: error });+ }+ }+ }+const storedDefaultValue =type === "date" ? defaultValue?.trim() : defaultValue;diff --git a/apps/api/src/custom-field/controllers/set-custom-field-value.ts b/apps/api/src/custom-field/controllers/set-custom-field-value.tsindex 119eb17c4..99349655a 100644--- a/apps/api/src/custom-field/controllers/set-custom-field-value.ts+++ b/apps/api/src/custom-field/controllers/set-custom-field-value.ts@@ -8,6 +8,17 @@ import {taskTable,} from "../../database/schema";+function isMultiselectEmpty(value: string): boolean {+ if (!value || value.trim().length === 0) return true;++ try {+ const parsed = JSON.parse(value);+ return Array.isArray(parsed) && parsed.length === 0;+ } catch {+ return false;+ }+}+async function setCustomFieldValue(taskId: string,fieldId: string,@@ -41,42 +52,76 @@ async function setCustomFieldValue(const normalizedValue = value.trim();- if (field.required && normalizedValue.length === 0) {- throw new HTTPException(400, {- message: "This custom field is required",- });+ if (field.required) {+ if (field.type === "multiselect") {+ if (isMultiselectEmpty(normalizedValue)) {+ throw new HTTPException(400, {+ message: "This custom field is required",+ });+ }+ } else if (normalizedValue.length === 0) {+ throw new HTTPException(400, {+ message: "This custom field is required",+ });+ }}- if (- field.type === "dropdown" &&- normalizedValue.length > 0 &&- Array.isArray(field.options) &&- !field.options.includes(normalizedValue)- ) {- throw new HTTPException(400, {- message: "Invalid option for this custom field",- });+ if (field.type === "dropdown" && normalizedValue.length > 0) {+ if (+ Array.isArray(field.options) &&+ !field.options.includes(normalizedValue)+ ) {+ throw new HTTPException(400, {+ message: "Invalid option for this custom field",+ });+ }}- if (- field.type === "number" &&- normalizedValue.length > 0 &&- Number.isNaN(Number(normalizedValue))- ) {- throw new HTTPException(400, {- message: "Value must be a valid number",- });+ if (field.type === "number" && normalizedValue.length > 0) {+ if (Number.isNaN(Number(normalizedValue))) {+ throw new HTTPException(400, {+ message: "Value must be a valid number",+ });+ }}- if (- field.type === "boolean" &&- normalizedValue.length > 0 &&- normalizedValue !== "true" &&- normalizedValue !== "false"- ) {- throw new HTTPException(400, {- message: "Value must be true or false",- });+ if (field.type === "boolean" && normalizedValue.length > 0) {+ if (normalizedValue !== "true" && normalizedValue !== "false") {+ throw new HTTPException(400, {+ message: "Value must be true or false",+ });+ }+ }++ if (field.type === "multiselect" && normalizedValue.length > 0) {+ let parsed: unknown;+ try {+ parsed = JSON.parse(normalizedValue);+ } catch {+ throw new HTTPException(400, {+ message: "Value must be a valid JSON array",+ });+ }++ if (!Array.isArray(parsed)) {+ throw new HTTPException(400, {+ message: "Value must be a JSON array",+ });+ }++ if (Array.isArray(field.options)) {+ const options = field.options as string[];++ const invalid = parsed.some(+ (v) => typeof v !== "string" || !options.includes(v),+ );++ if (invalid) {+ throw new HTTPException(400, {+ message: "Invalid option(s) for this custom field",+ });+ }+ }}const [result] = await dbdiff --git a/apps/api/src/custom-field/schema.ts b/apps/api/src/custom-field/schema.tsindex 8b9cfb878..d3ce0ca12 100644--- a/apps/api/src/custom-field/schema.ts+++ b/apps/api/src/custom-field/schema.ts@@ -15,7 +15,14 @@ export const customFieldIdParam = z.object({export const createCustomFieldBody = z.object({projectId: z.string(),name: z.string(),- type: z.enum(["text", "number", "date", "dropdown", "boolean"]),+ type: z.enum([+ "text",+ "number",+ "date",+ "dropdown",+ "boolean",+ "multiselect",+ ]),required: z.boolean().optional().default(false),defaultValue: z.string().optional(),options: z.array(z.string()).optional(),diff --git a/apps/api/src/task/controllers/create-task.ts b/apps/api/src/task/controllers/create-task.tsindex 7aaa66a2e..dd08fa955 100644--- a/apps/api/src/task/controllers/create-task.ts+++ b/apps/api/src/task/controllers/create-task.ts@@ -16,6 +16,7 @@ import {import {assertRequiredCustomFields,assertValidTaskStatus,+ isCustomFieldValueEmpty,} from "../validate-task-fields";import { claimTaskNumber } from "./claim-task-numbers";import { nextTaskPosition } from "./next-task-position";@@ -85,7 +86,15 @@ async function createTask({!providedFieldIds.has(field.id) &&field.required &&field.defaultValue != null &&- field.defaultValue.trim() !== ""+ !isCustomFieldValueEmpty(+ field.defaultValue,+ field.type as+ | "number"+ | "boolean"+ | "date"+ | "dropdown"+ | "multiselect",+ )) {mergedCustomFields.push({fieldId: field.id,diff --git a/apps/api/src/task/validate-task-fields.ts b/apps/api/src/task/validate-task-fields.tsindex 236210f9e..b2a70b33b 100644--- a/apps/api/src/task/validate-task-fields.ts+++ b/apps/api/src/task/validate-task-fields.ts@@ -3,9 +3,27 @@ import { HTTPException } from "hono/http-exception";import db from "../database";import { columnTable, customFieldDefinitionTable } from "../database/schema";+export function isCustomFieldValueEmpty(+ value: string,+ type: "number" | "boolean" | "date" | "dropdown" | "multiselect",+): boolean {+ if (value.trim() === "") return true;++ if (type === "multiselect") {+ try {+ const parsed = JSON.parse(value);+ return Array.isArray(parsed) && parsed.length === 0;+ } catch {+ return false;+ }+ }++ return false;+}+export function validateCustomFieldValue(value: string,- type: "number" | "boolean" | "date" | "dropdown",+ type: "number" | "boolean" | "date" | "dropdown" | "multiselect",fieldName: string,options?: unknown,): string | null {@@ -70,6 +88,37 @@ export function validateCustomFieldValue(}}+ if (type === "multiselect") {+ let parsedOptions: string[] = Array.isArray(options) ? options : [];++ if (typeof options === "string") {+ try {+ parsedOptions = JSON.parse(options);+ } catch {+ return `Custom field "${fieldName}" has invalid multiselect options.`;+ }+ }++ let selectedValues: unknown;+ try {+ selectedValues = JSON.parse(value);+ } catch {+ return `Custom field "${fieldName}" expects a JSON array of selected options, got "${value}".`;+ }++ if (!Array.isArray(selectedValues) || selectedValues.length === 0) {+ return `Custom field "${fieldName}" expects at least one selected option.`;+ }++ const invalidValues = selectedValues.filter(+ (v) => typeof v !== "string" || !parsedOptions.includes(v),+ );++ if (invalidValues.length > 0) {+ return `Custom field "${fieldName}" expects values from: ${parsedOptions.join(", ")}, got invalid value(s): ${invalidValues.join(", ")}.`;+ }+ }+return null;}@@ -100,13 +149,28 @@ export async function assertRequiredCustomFields(}for (const cf of customFields) {- if (cf.value.trim() === "") continue;const def = allFields.find((f) => f.id === cf.fieldId);if (!def) continue;+ const type = def.type as+ | "number"+ | "boolean"+ | "date"+ | "dropdown"+ | "multiselect";++ if (isCustomFieldValueEmpty(cf.value, type)) {+ if (def.required) {+ throw new HTTPException(400, {+ message: `Custom field "${def.name}" is required to create a task.`,+ });+ }+ continue;+ }+const error = validateCustomFieldValue(cf.value,- def.type as "number" | "boolean" | "date" | "dropdown",+ type,def.name,def.options,);@@ -117,13 +181,37 @@ export async function assertRequiredCustomFields(}const providedIds = new Set(- customFields.filter((f) => f.value.trim() !== "").map((f) => f.fieldId),+ customFields+ .filter((cf) => {+ const def = allFields.find((f) => f.id === cf.fieldId);+ if (!def) return false;++ return !isCustomFieldValueEmpty(+ cf.value,+ def.type as+ | "number"+ | "boolean"+ | "date"+ | "dropdown"+ | "multiselect",+ );+ })+ .map((f) => f.fieldId),);for (const field of allFields.filter((f) => f.required)) {const isSatisfied =providedIds.has(field.id) ||- (field.defaultValue != null && field.defaultValue.trim() !== "");+ (field.defaultValue != null &&+ !isCustomFieldValueEmpty(+ field.defaultValue,+ field.type as+ | "number"+ | "boolean"+ | "date"+ | "dropdown"+ | "multiselect",+ ));if (!isSatisfied) {throw new HTTPException(400, {diff --git a/apps/docs/openapi.json b/apps/docs/openapi.jsonindex c025064ae..96781dbe1 100644--- a/apps/docs/openapi.json+++ b/apps/docs/openapi.json@@ -15234,7 +15234,8 @@"number","date","dropdown",- "boolean"+ "boolean",+ "multiselect"]},"required": {diff --git a/apps/web/src/components/kanban-board/task-card.tsx b/apps/web/src/components/kanban-board/task-card.tsxindex e52cddd50..d7620dc5f 100644--- a/apps/web/src/components/kanban-board/task-card.tsx+++ b/apps/web/src/components/kanban-board/task-card.tsx@@ -140,9 +140,18 @@ function TaskCard({ task, disableDragDrop = false }: TaskCardProps) {const activeCustomFieldValues = useMemo(() =>- customFieldValues.filter(- (field) => field.value !== null && field.value !== "",- ),+ customFieldValues.filter((field) => {+ if (field.value === null || field.value === "") return false;+ if (field.fieldType === "multiselect") {+ try {+ const parsed = JSON.parse(field.value);+ return Array.isArray(parsed) && parsed.length > 0;+ } catch {+ return false;+ }+ }+ return true;+ }),[customFieldValues],);@@ -322,19 +331,37 @@ function TaskCard({ task, disableDragDrop = false }: TaskCardProps) {onPointerDown={(e) => e.stopPropagation()}><div className="space-y-1.5">- {activeCustomFieldValues.map((field) => (- <div- key={field.id}- className="flex items-center justify-between gap-2 text-xs"- >- <span className="font-medium text-muted-foreground truncate">- {field.fieldName}- </span>- <span className="text-foreground truncate max-w-24">- {field.value}- </span>- </div>- ))}+ {activeCustomFieldValues.map((field) => {+ const value = field.value;++ if (!value) return null;++ let displayValue: string = value;+ if (field.fieldType === "multiselect") {+ try {+ const parsed = JSON.parse(value);+ if (Array.isArray(parsed)) {+ displayValue = parsed.join(", ");+ }+ } catch {+ displayValue = value;+ }+ }++ return (+ <div+ key={field.id}+ className="flex items-center justify-between gap-2 text-xs"+ >+ <span className="font-medium text-muted-foreground truncate">+ {field.fieldName}+ </span>+ <span className="text-foreground truncate max-w-24">+ {displayValue}+ </span>+ </div>+ );+ })}</div></HoverCardContent></HoverCard>diff --git a/apps/web/src/components/project/custom-field-editor.tsx b/apps/web/src/components/project/custom-field-editor.tsxindex 29371f8df..1d0290bb3 100644--- a/apps/web/src/components/project/custom-field-editor.tsx+++ b/apps/web/src/components/project/custom-field-editor.tsx@@ -8,12 +8,23 @@ import {Plus,Trash2,Type,+ X,} from "lucide-react";-import { useEffect, useRef, useState } from "react";+import { useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { Button } from "@/components/ui/button";import { Calendar } from "@/components/ui/calendar";import { Checkbox } from "@/components/ui/checkbox";+import {+ Combobox,+ ComboboxChips,+ ComboboxChipsInput,+ ComboboxEmpty,+ ComboboxItem,+ ComboboxList,+ ComboboxPopup,+ ComboboxValue,+} from "@/components/ui/combobox";import { Input } from "@/components/ui/input";import {Popover,@@ -25,13 +36,6 @@ import {HoverCardContent,HoverCardTrigger,} from "@/components/ui/preview-card";-import {- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,-} from "@/components/ui/select";import useCreateCustomField from "@/hooks/mutations/custom-field/use-create-custom-field";import useDeleteCustomField from "@/hooks/mutations/custom-field/use-delete-custom-field";import { useReorderCustomFields } from "@/hooks/mutations/custom-field/use-reorder-custom-field";@@ -39,7 +43,13 @@ import useGetCustomFieldsByProject from "@/hooks/queries/custom-field/use-get-cuimport { toast } from "@/lib/toast";import { cn } from "@/lib/utils";-type CustomFieldType = "text" | "number" | "date" | "dropdown" | "boolean";+type CustomFieldType =+ | "text"+ | "number"+ | "date"+ | "dropdown"+ | "boolean"+ | "multiselect";export type CustomFieldDefinition = {id: string;@@ -57,12 +67,14 @@ export type CustomFieldDefinition = {const CUSTOM_FIELD_TYPES: Array<{value: CustomFieldType;icon: React.ElementType;+ availableOnTask?: boolean;}> = [- { value: "text", icon: Type },- { value: "number", icon: Hash },- { value: "date", icon: CalendarIcon },- { value: "dropdown", icon: List },- { value: "boolean", icon: CheckSquare },+ { value: "text", icon: Type, availableOnTask: true },+ { value: "number", icon: Hash, availableOnTask: true },+ { value: "date", icon: CalendarIcon, availableOnTask: true },+ { value: "dropdown", icon: List, availableOnTask: true },+ { value: "multiselect", icon: List, availableOnTask: false },+ { value: "boolean", icon: CheckSquare, availableOnTask: true },];type CustomFieldEditorProps = {@@ -89,7 +101,10 @@ export default function CustomFieldEditor({const [name, setName] = useState("");const [type, setType] = useState<CustomFieldType>("text");const [required, setRequired] = useState(false);- const [defaultValue, setDefaultValue] = useState("");++ const [isMultiple, setIsMultiple] = useState(false);++ const [defaultValue, setDefaultValue] = useState<string | string[]>("");const [optionsText, setOptionsText] = useState("");const [deletingFieldId, setDeletingFieldId] = useState<string | null>(null);@@ -101,6 +116,14 @@ export default function CustomFieldEditor({const dragPreviewRef = useRef<HTMLDivElement | null>(null);+ useEffect(() => {+ if (type !== "boolean") return;++ if (defaultValue !== "true" && defaultValue !== "false") {+ setDefaultValue("false");+ }+ }, [type, defaultValue]);+useEffect(() => {return () => {dragPreviewRef.current?.remove();@@ -117,24 +140,48 @@ export default function CustomFieldEditor({const options =type === "dropdown"- ? optionsText- .split(",")- .map((v) => v.trim())- .filter(Boolean)+ ? Array.from(+ new Set(+ optionsText+ .split(",")+ .map((v) => v.trim())+ .filter(Boolean),+ ),+ ): undefined;+ let apiDefaultValue: string | undefined;++ const apiType: CustomFieldType =+ type === "dropdown" && isMultiple ? "multiselect" : type;++ if (apiType === "multiselect") {+ if (Array.isArray(defaultValue) && defaultValue.length > 0) {+ apiDefaultValue = JSON.stringify(defaultValue);+ }+ } else if (apiType === "dropdown") {+ if (typeof defaultValue === "string" && defaultValue.trim() !== "") {+ apiDefaultValue = defaultValue;+ }+ } else if (typeof defaultValue === "string") {+ if (defaultValue.trim() !== "") {+ apiDefaultValue = defaultValue;+ }+ }+await createCustomField({projectId,name: name.trim(),- type,+ type: apiType,required,- defaultValue: defaultValue || undefined,+ defaultValue: apiDefaultValue,options,});setName("");setType("text");setRequired(false);+ setIsMultiple(false);setDefaultValue("");setOptionsText("");@@ -263,7 +310,7 @@ export default function CustomFieldEditor({toast.error(error instanceof Error? error.message- : t("settings:customFields.reorderError", "Failed to reorder fields"),+ : t("settings:customFields.reorderError"),);} finally {setIsReordering(false);@@ -273,10 +320,65 @@ export default function CustomFieldEditor({const hasExtraInput =type === "dropdown" || type === "date" || type === "boolean";- const dropdownOptions = optionsText- .split(",")- .map((v) => v.trim())- .filter(Boolean);+ const dropdownOptions = useMemo(() => {+ return Array.from(+ new Set(+ optionsText+ .split(",")+ .map((v) => v.trim())+ .filter(Boolean),+ ),+ );+ }, [optionsText]);++ useEffect(() => {+ if (type !== "dropdown") {+ if (isMultiple) setIsMultiple(false);+ if (Array.isArray(defaultValue)) {+ setDefaultValue(defaultValue[0] ?? "");+ } else if (+ type !== "boolean" &&+ (defaultValue === "true" || defaultValue === "false")+ ) {+ setDefaultValue("");+ }+ return;+ }++ if (isMultiple) {+ if (!Array.isArray(defaultValue)) {+ setDefaultValue(defaultValue ? [defaultValue] : []);+ }+ } else {+ if (Array.isArray(defaultValue)) {+ setDefaultValue(defaultValue[0] ?? "");+ }+ }+ }, [isMultiple, type, defaultValue]);++ useEffect(() => {+ if (type !== "dropdown") return;++ if (isMultiple) {+ if (Array.isArray(defaultValue)) {+ const stillValid = defaultValue.filter((v) =>+ dropdownOptions.includes(v),+ );+ if (stillValid.length !== defaultValue.length) {+ setDefaultValue(stillValid);+ }+ }+ } else {+ if (typeof defaultValue === "string" && defaultValue !== "") {+ if (+ dropdownOptions.length === 0 ||+ !dropdownOptions.includes(defaultValue)+ ) {+ setDefaultValue("");+ }+ }+ }+ }, [dropdownOptions, isMultiple, type, defaultValue]);const currentType = CUSTOM_FIELD_TYPES.find((t) => t.value === type);const CurrentIcon = currentType?.icon || Type;@@ -304,6 +406,26 @@ export default function CustomFieldEditor({const isDragging = draggedIndex === index;const isHovered = draggedIndex !== null && draggedIndex !== index;+ let defaultParsedValues: string[] | null = null;+ let defaultDisplayValue = field.defaultValue ?? "";++ if (field.defaultValue) {+ try {+ const parsed = JSON.parse(field.defaultValue);+ if (Array.isArray(parsed)) {+ defaultParsedValues = parsed;+ defaultDisplayValue = parsed.join(", ");+ }+ } catch {}+ }++ const defaultValueCanHover =+ Boolean(field.defaultValue) &&+ (field.type === "dropdown" || field.type === "multiselect") &&+ (defaultParsedValues+ ? defaultParsedValues.length > 0+ : Boolean(defaultDisplayValue));+return (// biome-ignore lint/a11y/useSemanticElements: false positive for role="listitem"<div@@ -323,31 +445,34 @@ export default function CustomFieldEditor({<GripVertical className="w-4 h-4 text-muted-foreground cursor-grab shrink-0" /><div className="min-w-0 flex-1"><div className="flex flex-wrap items-center gap-2">- <FieldIcon className="w-4 h-4 text-muted-foreground" />- <span className="truncate text-sm font-medium">+ <FieldIcon className="w-4 h-4 text-muted-foreground shrink-0" />+ <span className="min-w-0 max-w-[16rem] truncate text-sm font-medium">{field.name}</span>- <span className="rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground">+ <span className="shrink-0 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground">{t(`settings:customFields.types.${field.type}`)}</span>{field.required && (- <span className="rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground">+ <span className="shrink-0 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground">{t("settings:customFields.required")}</span>)}- {field.type === "dropdown" && field.options?.length ? (+ {(field.type === "dropdown" ||+ field.type === "multiselect") &&+ field.options?.length ? (<HoverCard><HoverCardTrigger asChild>- <span className="inline-flex items-center gap-1 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground cursor-pointer hover:bg-muted/80 transition-colors">- {field.options.length}{" "}- {t("settings:customFields.options", "options")}+ <span className="shrink-0 inline-flex items-center gap-1 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground cursor-pointer hover:bg-muted/80 transition-colors">+ {t("settings:customFields.options", {+ count: field.options.length,+ })}</span></HoverCardTrigger><HoverCardContent- className="w-64 max-w-[calc(100vw-3rem)]"+ className="w-64 max-w-[calc(100vw-3rem)] overflow-hidden"align="start">- <div className="space-y-1.5">+ <div className="min-w-0 space-y-1.5"><div className="text-xs font-medium text-muted-foreground">{t("settings:customFields.availableOptions",@@ -355,11 +480,11 @@ export default function CustomFieldEditor({)}</div>- <div className="flex max-h-48 flex-wrap gap-1.5 overflow-y-auto">+ <div className="flex min-w-0 max-h-48 flex-wrap gap-1.5 overflow-y-auto overflow-x-hidden">{field.options.map((option) => (<spankey={`field_${field.id}_option_${option}`}- className="max-w-full whitespace-normal break-words rounded bg-secondary px-2.5 py-1 text-xs"+ className="min-w-0 max-w-full whitespace-normal break-all rounded bg-secondary px-2.5 py-1 text-xs">{option}</span>@@ -369,14 +494,52 @@ export default function CustomFieldEditor({</HoverCardContent></HoverCard>) : null}- {field.defaultValue && (- <span className="truncate text-xs text-muted-foreground">- {t("settings:customFields.defaultLabel")}:{" "}- <span className="text-foreground">- {field.defaultValue}+ {field.defaultValue &&+ (defaultValueCanHover ? (+ <HoverCard>+ <HoverCardTrigger asChild>+ <span className="shrink-0 inline-flex items-center gap-1 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground cursor-pointer hover:bg-muted/80 transition-colors">+ {t("settings:customFields.defaultValues", {+ count: defaultParsedValues?.length ?? 1,+ })}+ </span>+ </HoverCardTrigger>+ <HoverCardContent+ className="w-64 max-w-[calc(100vw-3rem)] overflow-hidden"+ align="start"+ >+ <div className="min-w-0 space-y-1.5">+ <div className="text-xs font-medium text-muted-foreground">+ {t("settings:customFields.defaultLabel")}+ </div>++ {defaultParsedValues ? (+ <div className="flex min-w-0 max-h-48 flex-wrap gap-1.5 overflow-y-auto overflow-x-hidden">+ {defaultParsedValues.map((value) => (+ <span+ key={`field_${field.id}_default_${value}`}+ className="min-w-0 max-w-full whitespace-normal break-all rounded bg-secondary px-2.5 py-1 text-xs"+ >+ {value}+ </span>+ ))}+ </div>+ ) : (+ <p className="min-w-0 max-w-full whitespace-normal break-words text-xs text-foreground">+ {defaultDisplayValue}+ </p>+ )}+ </div>+ </HoverCardContent>+ </HoverCard>+ ) : (+ <span className="min-w-0 max-w-[12rem] truncate text-xs text-muted-foreground">+ {t("settings:customFields.defaultLabel")}:{" "}+ <span className="text-foreground">+ {defaultDisplayValue}+ </span></span>- </span>- )}+ ))}</div></div><Button@@ -413,26 +576,28 @@ export default function CustomFieldEditor({</PopoverTrigger><PopoverContent className="w-48" align="start"><div className="space-y-1 px-0.5 py-1">- {CUSTOM_FIELD_TYPES.map((item) => {- const Icon = item.icon;- return (- <Button- key={item.value}- type="button"- variant="ghost"- size="sm"- onClick={() => setType(item.value)}- className={cn(- "w-full justify-start gap-2 text-sm rounded-sm",- type === item.value &&- "bg-sidebar-accent text-sidebar-accent-foreground",- )}- >- <Icon className="h-4 w-4" />- {t(`settings:customFields.types.${item.value}`)}- </Button>- );- })}+ {CUSTOM_FIELD_TYPES.filter((item) => item.availableOnTask).map(+ (item) => {+ const Icon = item.icon;+ return (+ <Button+ key={item.value}+ type="button"+ variant="ghost"+ size="sm"+ onClick={() => setType(item.value)}+ className={cn(+ "w-full justify-start gap-2 text-sm rounded-sm",+ type === item.value &&+ "bg-sidebar-accent text-sidebar-accent-foreground",+ )}+ >+ <Icon className="h-4 w-4" />+ {t(`settings:customFields.types.${item.value}`)}+ </Button>+ );+ },+ )}</div></PopoverContent></Popover>@@ -463,11 +628,14 @@ export default function CustomFieldEditor({variant="outline"className={cn("h-8 w-48 flex-[2_0_0] justify-start bg-background text-left text-sm font-normal",- !defaultValue && "text-muted-foreground",+ !(typeof defaultValue === "string" && defaultValue) &&+ "text-muted-foreground",)}><CalendarIcon className="mr-2 h-4 w-4 opacity-70" />- {defaultValue && isValid(parseISO(defaultValue))+ {typeof defaultValue === "string" &&+ defaultValue &&+ isValid(parseISO(defaultValue))? format(parseISO(defaultValue), "dd MMM yyyy"): t("tasks:detail.pickDate", "Pick a date")}</Button>@@ -476,7 +644,9 @@ export default function CustomFieldEditor({<Calendarmode="single"selected={- defaultValue && isValid(parseISO(defaultValue))+ typeof defaultValue === "string" &&+ defaultValue &&+ isValid(parseISO(defaultValue))? parseISO(defaultValue): undefined}@@ -490,54 +660,256 @@ export default function CustomFieldEditor({)}{type === "boolean" ? (- <Select- value={defaultValue ?? "false"}- onValueChange={(value) => setDefaultValue(value as string)}- >- <SelectTrigger className="h-8 w-48 flex-[2_0_0] text-sm">- <SelectValue- placeholder={t("settings:customFields.defaultValuePlaceholder")}- />- </SelectTrigger>- <SelectContent>- <SelectItem value="true">{t("common:true", "True")}</SelectItem>- <SelectItem value="false">- {t("common:false", "False")}- </SelectItem>- </SelectContent>- </Select>+ <div className="inline-flex h-8 w-48 flex-[2_0_0] items-center overflow-hidden rounded-lg border text-xs">+ {(["true", "false"] as const).map((val) => {+ const isSelected = defaultValue === val;+ return (+ <button+ key={val}+ type="button"+ onClick={() => setDefaultValue(val)}+ className={cn(+ "flex-1 h-full flex items-center justify-center capitalize transition-colors",+ isSelected+ ? "bg-foreground text-background font-medium"+ : "text-muted-foreground hover:bg-muted",+ )}+ aria-pressed={isSelected}+ >+ {val === "true"+ ? t("common:boolean.true", "True")+ : t("common:boolean.false", "False")}+ </button>+ );+ })}+ </div>) : type === "dropdown" ? (- <Select- value={defaultValue}- onValueChange={(value) => setDefaultValue(value as string)}- disabled={dropdownOptions.length === 0}- >- <SelectTrigger className="h-8 w-48 flex-[2_0_0] text-sm disabled:opacity-50">- <SelectValue- placeholder={- dropdownOptions.length === 0- ? t(- "settings:customFields.noOptionsPlaceholder",- "No options",- )- : t(- "settings:customFields.defaultValuePlaceholder",- "Default value",- )- }- />- </SelectTrigger>- <SelectContent>- {dropdownOptions.map((option) => (- <SelectItem key={`field_option_${option}`} value={option}>- {option}- </SelectItem>- ))}- </SelectContent>- </Select>+ <>+ <Combobox+ key={isMultiple ? "multi" : "single"}+ multiple={isMultiple}+ autoHighlight+ items={dropdownOptions}+ value={+ isMultiple+ ? Array.isArray(defaultValue)+ ? defaultValue+ : []+ : typeof defaultValue === "string"+ ? defaultValue+ : ""+ }+ onValueChange={(value) => {+ setDefaultValue(isMultiple ? (value ?? []) : (value ?? ""));+ }}+ disabled={dropdownOptions.length === 0}+ >+ <ComboboxChips+ className={cn(+ "h-8 min-w-0 w-48 flex-[2_0_0] select-none cursor-default",+ "overflow-hidden",+ "flex-nowrap",+ )}+ >+ <ComboboxValue>+ {(values: string[] | string) => {+ const selected: string[] = isMultiple+ ? Array.isArray(values)+ ? values.filter((v) => v !== "")+ : []+ : typeof values === "string" && values !== ""+ ? [values]+ : [];++ const MAX_VISIBLE_CHIPS = 3;+ const visibleChips = selected.slice(0, MAX_VISIBLE_CHIPS);+ const hiddenCount = selected.length - MAX_VISIBLE_CHIPS;++ return (+ <>+ {visibleChips.map((value) => {+ if (isMultiple) {+ return (+ <div+ key={value}+ className={cn(+ "min-w-0 max-w-full flex-1 shrink basis-0",+ "inline-flex items-center overflow-hidden",+ "rounded-md bg-secondary px-1.5 py-0.5",+ "select-none cursor-default",+ )}+ >+ <span className="block min-w-0 max-w-full truncate text-xs text-secondary-foreground">+ {value}+ </span>+ </div>+ );+ }+ return (+ <div+ key={value}+ className={cn(+ "min-w-0 max-w-full flex-1 shrink basis-0",+ "inline-flex items-center overflow-hidden",+ "ps-1.5",+ "select-none cursor-default",+ )}+ >+ <span className="block min-w-0 max-w-full truncate text-xs">+ {value}+ </span>+ </div>+ );+ })}++ {selected.length > MAX_VISIBLE_CHIPS && (+ <HoverCard>+ <HoverCardTrigger asChild>+ <button+ type="button"+ className="shrink-0 inline-flex items-center gap-1 text-xs font-medium cursor-pointer text-foreground/50 pe-1"+ onClick={(e) => {+ e.stopPropagation();+ e.preventDefault();+ }}+ onPointerDown={(e) => {+ e.stopPropagation();+ e.preventDefault();+ }}+ >+ {t("settings:customFields.moreOptions", {+ hiddenCount,+ })}+ </button>+ </HoverCardTrigger>++ <HoverCardContent+ side="top"+ align="start"+ className="flex max-w-xs flex-wrap gap-1 overflow-hidden"+ >+ <div className="min-w-0 space-y-1.5">+ <div className="text-xs font-medium text-muted-foreground">+ {t(+ "settings:customFields.availableOptions",+ "Available options",+ )}+ </div>++ <div className="flex min-w-0 max-h-48 flex-wrap gap-x-1.5 gap-y-1.5 overflow-y-auto overflow-x-hidden">+ {selected+ .slice(MAX_VISIBLE_CHIPS)+ .map((value) => (+ <div+ key={value}+ className={cn(+ "min-w-0 max-w-full",+ "inline-flex items-center overflow-hidden",+ "rounded bg-secondary px-1.5 py-0.5",+ "select-none cursor-default",+ )}+ >+ <span className="block min-w-0 max-w-[14rem] truncate text-xs">+ {value}+ </span>+ </div>+ ))}+ </div>+ </div>+ </HoverCardContent>+ </HoverCard>+ )}++ <ComboboxChipsInput+ className={cn(+ "min-w-0 flex-1 caret-transparent",+ selected.length > 0 && "hidden",+ "pointer-events-none",+ "placeholder:text-foreground/50",+ isMultiple && "text-transparent",+ )}+ placeholder={+ dropdownOptions.length === 0+ ? t(+ "settings:customFields.noOptionsPlaceholder",+ "No options",+ )+ : selected.length === 0+ ? t(+ "settings:customFields.defaultValuePlaceholder",+ "Default value",+ )+ : undefined+ }+ />++ {!isMultiple && !required && selected.length > 0 && (+ <button+ type="button"+ className="ml-auto shrink-0 rounded-sm p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"+ onMouseDown={(e) => {+ e.preventDefault();+ e.stopPropagation();+ }}+ onClick={(e) => {+ e.stopPropagation();+ setDefaultValue("");+ }}+ aria-label={t(+ "settings:customFields.clearDefault",+ "Clear",+ )}+ >+ <X className="h-3.5 w-3.5" />+ </button>+ )}+ </>+ );+ }}+ </ComboboxValue>+ </ComboboxChips>++ <ComboboxPopup>+ <ComboboxEmpty>+ {t(+ "settings:customFields.noOptionsPlaceholder",+ "No options",+ )}+ </ComboboxEmpty>++ <ComboboxList>+ {(option: string) => (+ <ComboboxItem+ className="min-w-0 max-w-full"+ key={`field_option_${option}`}+ value={option}+ >+ <span className="block max-w-38 truncate">{option}</span>+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxPopup>+ </Combobox>+ <Checkbox+ id="dropdown-multiple"+ checked={isMultiple}+ onCheckedChange={(checked) => {+ const next = Boolean(checked);+ setIsMultiple(next);+ setDefaultValue(next ? [] : "");+ }}+ className="h-4 w-4"+ />+ <label+ htmlFor="dropdown-multiple"+ className="text-xs text-muted-foreground whitespace-nowrap"+ >+ {t("settings:customFields.multiple")}+ </label>+ </>) : type === "number" ? (<Input- value={defaultValue}+ value={typeof defaultValue === "string" ? defaultValue : ""}type="number"onChange={(e) => setDefaultValue(e.target.value)}placeholder={t("settings:customFields.defaultValuePlaceholder")}@@ -577,8 +949,12 @@ export default function CustomFieldEditor({disabled={!name.trim() ||savingField ||- (type === "dropdown" && !optionsText.trim()) ||- (required && !defaultValue)+ (required &&+ (Array.isArray(defaultValue)+ ? defaultValue.length === 0+ : !defaultValue)) ||+ (type === "dropdown" &&+ dropdownOptions.length < (isMultiple ? 2 : 1))}className="h-8 gap-1 shrink-0">diff --git a/apps/web/src/components/shared/modals/create-task-modal.tsx b/apps/web/src/components/shared/modals/create-task-modal.tsxindex 30555be0b..fe17af176 100644--- a/apps/web/src/components/shared/modals/create-task-modal.tsx+++ b/apps/web/src/components/shared/modals/create-task-modal.tsx@@ -13,6 +13,12 @@ import {import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import TaskDescriptionEditor from "@/components/task/task-description-editor";+import {+ Accordion,+ AccordionContent,+ AccordionItem,+ AccordionTrigger,+} from "@/components/ui/accordion";import {AlertDialog,AlertDialogClose,@@ -32,6 +38,16 @@ import {} from "@/components/ui/breadcrumb";import { Button } from "@/components/ui/button";import { Calendar } from "@/components/ui/calendar";+import {+ Combobox,+ ComboboxChips,+ ComboboxChipsInput,+ ComboboxEmpty,+ ComboboxItem,+ ComboboxList,+ ComboboxPopup,+ ComboboxValue,+} from "@/components/ui/combobox";import {Dialog,DialogContent,@@ -46,6 +62,11 @@ import {PopoverContent,PopoverTrigger,} from "@/components/ui/popover";+import {+ HoverCard,+ HoverCardContent,+ HoverCardTrigger,+} from "@/components/ui/preview-card";import {Select,SelectContent,@@ -105,7 +126,13 @@ type Label = {type PopoverStep = "select" | "color";-type CustomFieldType = "text" | "number" | "date" | "dropdown" | "boolean";+type CustomFieldType =+ | "text"+ | "number"+ | "date"+ | "dropdown"+ | "boolean"+ | "multiselect";type CustomFieldDefinition = {id: string;@@ -321,6 +348,14 @@ function CreateTaskModalContent({}, {});}, [customFields]);+ const hasCustomFieldChanges = Object.entries(customFieldValues).some(+ ([fieldId, value]) => {+ const field = customFields.find((f) => f.id === fieldId);+ const defaultValue = field?.defaultValue ?? "";+ return value !== defaultValue;+ },+ );+const hasUnsavedChanges = Boolean(title.trim() ||description.trim() ||@@ -330,7 +365,8 @@ function CreateTaskModalContent({dueDate ||selectedProjectId ||labels.length > 0 ||- draftTask,+ draftTask ||+ hasCustomFieldChanges,);const discardDraft = useCallback(() => {@@ -790,7 +826,7 @@ function CreateTaskModalContent({<SelectContent>{options.map((opt) => (<SelectItem key={opt} value={opt}>- {opt}+ <span className="block max-w-50 truncate">{opt}</span></SelectItem>))}</SelectContent>@@ -835,6 +871,158 @@ function CreateTaskModalContent({</div>);+ case "multiselect": {+ const selectedValues: string[] = (() => {+ if (!value) return [];+ try {+ const parsed = JSON.parse(value);+ return Array.isArray(parsed) ? parsed : [];+ } catch {+ return value.split(",").filter((v) => v.length > 0);+ }+ })();+ const MAX_VISIBLE_CHIPS = 3;++ return (+ <Combobox+ multiple={true}+ autoHighlight+ items={Array.from(new Set(field.options ?? []))}+ value={selectedValues}+ onValueChange={(val) =>+ handleCustomFieldChange(field.id, JSON.stringify(val))+ }+ >+ <ComboboxChips className="h-9 w-full flex-[2_0_0] select-none cursor-default text-sm disabled:opacity-50">+ <ComboboxValue>+ {(values: string[]) => {+ const visibleChips = values.slice(0, MAX_VISIBLE_CHIPS);+ const hiddenCount = values.length - MAX_VISIBLE_CHIPS;++ return (+ <>+ {visibleChips.map((value) => (+ <div+ key={value}+ className={cn(+ "min-w-0 max-w-full flex-1 shrink basis-0",+ "inline-flex items-center overflow-hidden",+ "rounded-md bg-secondary px-1.5 py-0.5",+ "select-none cursor-default",+ )}+ >+ <span className="block min-w-0 max-w-full truncate text-xs text-secondary-foreground">+ {value}+ </span>+ </div>+ ))}+ {values.length > MAX_VISIBLE_CHIPS && (+ <HoverCard>+ <HoverCardTrigger asChild>+ <button+ type="button"+ className="shrink-0 inline-flex items-center gap-1 text-xs font-medium cursor-pointer text-foreground/50 pe-1"+ onClick={(e) => {+ e.stopPropagation();+ e.preventDefault();+ }}+ onPointerDown={(e) => {+ e.stopPropagation();+ e.preventDefault();+ }}+ >+ {t("settings:customFields.moreOptions", {+ hiddenCount,+ })}+ </button>+ </HoverCardTrigger>++ <HoverCardContent+ side="top"+ align="start"+ className="flex max-w-xs flex-wrap gap-1"+ >+ <div className="space-y-1.5">+ <div className="text-xs font-medium text-muted-foreground">+ {t(+ "settings:customFields.availableOptions",+ "Available options",+ )}+ </div>++ <div className="flex min-w-0 max-h-48 flex-wrap gap-x-1.5 gap-y-1.5 overflow-y-auto overflow-x-hidden">+ {values+ .slice(MAX_VISIBLE_CHIPS)+ .map((value) => (+ <div+ key={value}+ className={cn(+ "min-w-0 max-w-full",+ "inline-flex items-center overflow-hidden",+ "rounded bg-secondary px-1.5 py-0.5",+ "select-none cursor-default",+ )}+ >+ <span className="block min-w-0 max-w-[13rem] truncate text-xs">+ {value}+ </span>+ </div>+ ))}+ </div>+ </div>+ </HoverCardContent>+ </HoverCard>+ )}++ <ComboboxChipsInput+ className={cn(+ "min-w-0 flex-1 caret-transparent",+ values.length > 0 && "hidden",+ "pointer-events-none",+ "placeholder:text-foreground/50",+ "text-transparent",+ )}+ placeholder={+ Array.from(new Set(field.options ?? [])).length === 0+ ? t(+ "settings:customFields.noOptionsPlaceholder",+ "No options",+ )+ : values.length === 0+ ? t(+ "settings:customFields.defaultValuePlaceholder",+ "Default value",+ )+ : undefined+ }+ />+ </>+ );+ }}+ </ComboboxValue>+ </ComboboxChips>++ <ComboboxPopup>+ <ComboboxEmpty>+ {t("settings:customFields.noOptionsPlaceholder", "No options")}+ </ComboboxEmpty>++ <ComboboxList>+ {(option: string) => (+ <ComboboxItem+ className="min-w-0 max-w-full"+ key={`field_option_${option}`}+ value={option}+ >+ <span className="block max-w-50 truncate">{option}</span>+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxPopup>+ </Combobox>+ );+ }+default:return (<Input@@ -909,29 +1097,60 @@ function CreateTaskModalContent({</div>{customFields.length > 0 && (- <div className="space-y-4 pt-4 border-t border-border">- <h4 className="text-sm font-semibold text-foreground">- {t("tasks:common.customFields")}- </h4>- <div className="grid gap-4 sm:grid-cols-2">- {customFields.map((field) => (- <div- key={`custom-field_${field.id}`}- className="space-y-1.5"- >- <label- htmlFor={`custom-field_${field.id}`}- className="text-xs font-medium text-muted-foreground flex items-center gap-1"- >- {field.name}- {field.required && (- <span className="text-destructive">*</span>- )}- </label>- {renderCustomFieldInput(field)}- </div>- ))}- </div>+ <div className="mt-2">+ <Accordion+ key={resolvedProjectId}+ className="w-full"+ defaultValue={+ customFields.some((field) => field.required)+ ? ["custom-fields"]+ : []+ }+ >+ <AccordionItem+ value="custom-fields"+ className="rounded-lg border border-border bg-sidebar/30 px-4"+ >+ <AccordionTrigger className="py-4 hover:no-underline">+ <div className="flex items-center gap-2 text-left">+ <span className="text-sm font-semibold text-foreground">+ {t("tasks:common.customFields")}+ </span>+ <span className="rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground">+ {customFields.length}+ </span>+ </div>+ </AccordionTrigger>++ <AccordionContent className="pb-4">+ <div className="grid gap-4 sm:grid-cols-2">+ <div className="space-y-4 pt-4 border-t border-border sm:col-span-2">+ <div className="grid gap-4 sm:grid-cols-2">+ {customFields.map((field) => (+ <div+ key={`custom-field_${field.id}`}+ className="space-y-1.5"+ >+ <label+ htmlFor={`custom-field_${field.id}`}+ className="text-xs font-medium text-muted-foreground flex items-center gap-1"+ >+ {field.name}+ {field.required && (+ <span className="text-destructive">*</span>+ )}+ </label>+ <div className="w-full">+ {renderCustomFieldInput(field)}+ </div>+ </div>+ ))}+ </div>+ </div>+ </div>+ </AccordionContent>+ </AccordionItem>+ </Accordion></div>)}diff --git a/apps/web/src/components/task/task-details-content.tsx b/apps/web/src/components/task/task-details-content.tsxindex 6261adf8e..0ac54c12b 100644--- a/apps/web/src/components/task/task-details-content.tsx+++ b/apps/web/src/components/task/task-details-content.tsx@@ -16,12 +16,27 @@ import {} from "@/components/ui/accordion";import { Button } from "@/components/ui/button";import { Calendar } from "@/components/ui/calendar";+import {+ Combobox,+ ComboboxChips,+ ComboboxChipsInput,+ ComboboxEmpty,+ ComboboxItem,+ ComboboxList,+ ComboboxPopup,+ ComboboxValue,+} from "@/components/ui/combobox";import { Input } from "@/components/ui/input";import {Popover,PopoverContent,PopoverTrigger,} from "@/components/ui/popover";+import {+ HoverCard,+ HoverCardContent,+ HoverCardTrigger,+} from "@/components/ui/preview-card";import {Select,SelectContent,@@ -48,7 +63,13 @@ import TaskRelations from "./task-relations";import TaskSubtasks from "./task-subtasks";import TaskTitle from "./task-title";-type CustomFieldType = "text" | "number" | "date" | "dropdown" | "boolean";+type CustomFieldType =+ | "text"+ | "number"+ | "date"+ | "dropdown"+ | "boolean"+ | "multiselect";type CustomFieldDefinition = {id: string;@@ -63,6 +84,8 @@ type CustomFieldDefinition = {updatedAt: string;};+type CustomFieldValueMap = Record<string, string | string[]>;+type TaskDetailsContentProps = {taskId: string | undefined;projectId: string;@@ -70,6 +93,20 @@ type TaskDetailsContentProps = {className?: string;};+function safeParseMultiselect(raw: string | null | undefined): string[] {+ if (!raw) return [];+ try {+ const parsed = JSON.parse(raw);+ if (Array.isArray(parsed)) return parsed as string[];+ return [];+ } catch {+ return raw+ .split(",")+ .map((s) => s.trim())+ .filter(Boolean);+ }+}+export default function TaskDetailsContent({taskId,projectId,@@ -98,47 +135,69 @@ export default function TaskDetailsContent({const { canUpdateTasks } = useWorkspacePermission();const canEdit = canUpdateTasks();- const [localValues, setLocalValues] = useState<Record<string, string>>({});+ const [localValues, setLocalValues] = useState<CustomFieldValueMap>({});useEffect(() => {- const valuesMap: Record<string, string> = {};+ const valuesMap: CustomFieldValueMap = {};for (const field of customFields) {- valuesMap[field.id] = field.defaultValue || "";+ valuesMap[field.id] = field.type === "multiselect" ? [] : "";}for (const val of customFieldValues) {- if (val.value !== null) {- valuesMap[val.fieldId] = val.value;- }+ const field = customFields.find((f) => f.id === val.fieldId);++ if (!field) continue;++ valuesMap[val.fieldId] =+ field.type === "multiselect"+ ? safeParseMultiselect(val.value)+ : (val.value ?? "");}setLocalValues(valuesMap);}, [customFields, customFieldValues]);- const handleLocalChange = (fieldId: string, val: string) => {- setLocalValues((prev) => ({ ...prev, [fieldId]: val }));+ const handleLocalChange = (fieldId: string, val: string | string[]) => {+ setLocalValues((prev: CustomFieldValueMap) => ({+ ...prev,+ [fieldId]: val,+ }));};- const handleSaveField = async (fieldId: string, value: string) => {+ const handleSaveField = async (fieldId: string, value: string | string[]) => {if (!taskId) return;+ const field = customFields.find((f) => f.id === fieldId);const existingValObj = customFieldValues.find((v) => v.fieldId === fieldId);- const existingVal = existingValObj ? (existingValObj.value ?? "") : "";+ const existingRaw = existingValObj ? (existingValObj.value ?? "") : "";- if (value === existingVal) return;+ const isMultiselect = field?.type === "multiselect";++ const serializedValue = isMultiselect+ ? JSON.stringify(value as string[])+ : (value as string);++ const existingComparable = isMultiselect+ ? JSON.stringify(safeParseMultiselect(existingRaw))+ : existingRaw;++ if (serializedValue === existingComparable) return;try {await setCustomFieldValue({taskId,fieldId,- value,+ value: serializedValue,projectId,});toast.success(t("tasks:detail.customFieldUpdated", "Field updated"));} catch (error) {- handleLocalChange(fieldId, existingVal);+ handleLocalChange(+ fieldId,+ isMultiselect ? safeParseMultiselect(existingRaw) : existingRaw,+ );toast.error(error instanceof Error ? error.message : "Failed to update field",);@@ -207,6 +266,10 @@ export default function TaskDetailsContent({<div className="grid gap-4 sm:grid-cols-2">{customFields.map((field) => {const val = localValues[field.id] ?? "";+ const multiselectVal: string[] = Array.isArray(val)+ ? val+ : [];+ const textVal: string = Array.isArray(val) ? "" : val;return (<div@@ -225,7 +288,7 @@ export default function TaskDetailsContent({{field.type === "dropdown" ? (<Select- value={val}+ value={textVal}onValueChange={(newVal) => {handleLocalChange(field.id, newVal as string);void handleSaveField(field.id, newVal as string);@@ -240,17 +303,21 @@ export default function TaskDetailsContent({)}/></SelectTrigger>- <SelectContent>+ <SelectContent className="max-w-[25rem]">{!field.required && (<SelectItem key="empty" value="">{t("tasks:detail.selectOption")}</SelectItem>)}- {(field.options || []).map((opt) => (- <SelectItem key={opt} value={opt}>- {opt}- </SelectItem>- ))}+ {Array.from(new Set(field.options || [])).map(+ (opt) => (+ <SelectItem key={opt} value={opt}>+ <span className="block max-w-38 truncate">+ {opt}+ </span>+ </SelectItem>+ ),+ )}</SelectContent></Select>) : field.type === "date" ? (@@ -264,14 +331,17 @@ export default function TaskDetailsContent({disabled={!canEdit}className={cn("h-10! w-full justify-start rounded-md bg-background pr-10 text-left text-sm font-normal",- !val && "text-muted-foreground",+ !textVal && "text-muted-foreground",)}><CalendarIcon className="mr-2 size-4 shrink-0 opacity-70" /><span className="truncate">- {val && isValid(parseISO(val))- ? format(parseISO(val), "dd MMM yyyy")+ {textVal && isValid(parseISO(textVal))+ ? format(+ parseISO(textVal),+ "dd MMM yyyy",+ ): t("tasks:detail.pickDate","Pick a date",@@ -289,8 +359,8 @@ export default function TaskDetailsContent({<Calendarmode="single"selected={- val && isValid(parseISO(val))- ? parseISO(val)+ textVal && isValid(parseISO(textVal))+ ? parseISO(textVal): undefined}onSelect={(date) => {@@ -310,14 +380,14 @@ export default function TaskDetailsContent({<Buttonvariant="ghost"type="button"- disabled={!canEdit || !val}+ disabled={!canEdit || !textVal}onClick={() => {handleLocalChange(field.id, "");void handleSaveField(field.id, "");}}className={cn("absolute right-1 top-1/2 z-10 size-8 -translate-y-1/2 rounded-md p-0 text-muted-foreground",- canEdit && val+ canEdit && textVal? "hover:bg-destructive/10 hover:text-destructive": "cursor-not-allowed",)}@@ -336,11 +406,14 @@ export default function TaskDetailsContent({) : field.type === "number" ? (<Inputtype="number"- value={val}+ value={textVal}+ placeholder={field.defaultValue?.toString()}onChange={(e) =>handleLocalChange(field.id, e.target.value)}- onBlur={() => void handleSaveField(field.id, val)}+ onBlur={() =>+ void handleSaveField(field.id, textVal)+ }disabled={!canEdit}className="h-9 w-full bg-background text-sm"/>@@ -353,11 +426,11 @@ export default function TaskDetailsContent({)}><span className="flex-1 truncate text-foreground">- {t(`common:boolean.${val || "notSet"}`)}+ {t(`common:boolean.${textVal || "notSet"}`)}</span><Switch- checked={val === "true"}+ checked={textVal === "true"}onCheckedChange={(checked) => {const nextValue = checked ? "true" : "false";@@ -393,14 +466,177 @@ export default function TaskDetailsContent({</Button>)}</div>+ ) : field.type === "multiselect" ? (+ <Combobox+ multiple={true}+ autoHighlight+ items={Array.from(new Set(field.options ?? []))}+ value={multiselectVal}+ onValueChange={(newVal) => {+ const nextVal = newVal as string[];+ handleLocalChange(field.id, nextVal);+ }}+ onOpenChange={(open) => {+ if (!open) {+ handleLocalChange(field.id, multiselectVal);+ void handleSaveField(field.id, multiselectVal);+ }+ }}+ disabled={!canEdit}+ >+ <ComboboxChips className="h-9 w-full flex-[2_0_0] select-none cursor-default text-sm disabled:opacity-50">+ <ComboboxValue>+ {(values: string[]) => {+ const MAX_VISIBLE_CHIPS = 3;+ const visibleChips = values.slice(+ 0,+ MAX_VISIBLE_CHIPS,+ );+ const hiddenCount =+ values.length - MAX_VISIBLE_CHIPS;++ return (+ <>+ {visibleChips.map((value) => (+ <div+ key={value}+ className={cn(+ "min-w-0 max-w-full flex-1 shrink basis-0",+ "inline-flex items-center overflow-hidden",+ "rounded-md bg-secondary px-1.5 py-0.5",+ "select-none cursor-default",+ )}+ >+ <span className="block min-w-0 max-w-full truncate text-xs text-secondary-foreground">+ {value}+ </span>+ </div>+ ))}+ {values.length > MAX_VISIBLE_CHIPS && (+ <HoverCard>+ <HoverCardTrigger asChild>+ <button+ type="button"+ className="shrink-0 inline-flex items-center gap-1 text-xs font-medium cursor-pointer text-foreground/50 pe-1"+ onClick={(e) => {+ e.stopPropagation();+ e.preventDefault();+ }}+ onPointerDown={(e) => {+ e.stopPropagation();+ e.preventDefault();+ }}+ >+ {t(+ "settings:customFields.moreOptions",+ {+ hiddenCount,+ },+ )}+ </button>+ </HoverCardTrigger>++ <HoverCardContent+ side="top"+ align="start"+ className="flex max-w-xs flex-wrap gap-1"+ >+ <div className="space-y-1.5">+ <div className="text-xs font-medium text-muted-foreground">+ {t(+ "settings:customFields.availableOptions",+ "Available options",+ )}+ </div>++ <div className="flex min-w-0 max-h-48 flex-wrap gap-x-1.5 gap-y-1.5 overflow-y-auto overflow-x-hidden">+ {values+ .slice(MAX_VISIBLE_CHIPS)+ .map((value) => (+ <div+ key={value}+ className={cn(+ "min-w-0 max-w-full",+ "inline-flex items-center overflow-hidden",+ "rounded bg-secondary px-1.5 py-0.5",+ "select-none cursor-default",+ )}+ >+ <span className="block min-w-0 max-w-[13rem] truncate text-xs">+ {value}+ </span>+ </div>+ ))}+ </div>+ </div>+ </HoverCardContent>+ </HoverCard>+ )}++ <ComboboxChipsInput+ className={cn(+ "min-w-0 flex-1 caret-transparent",+ values.length > 0 && "hidden",+ "pointer-events-none",+ "placeholder:text-foreground/50",+ "text-transparent",+ )}+ placeholder={+ Array.from(+ new Set(field.options ?? []),+ ).length === 0+ ? t(+ "settings:customFields.noOptionsPlaceholder",+ "No options",+ )+ : values.length === 0+ ? t(+ "settings:customFields.defaultValuePlaceholder",+ "Default value",+ )+ : undefined+ }+ />+ </>+ );+ }}+ </ComboboxValue>+ </ComboboxChips>++ <ComboboxPopup>+ <ComboboxEmpty>+ {t(+ "settings:customFields.noOptionsPlaceholder",+ "No options",+ )}+ </ComboboxEmpty>++ <ComboboxList>+ {(option: string) => (+ <ComboboxItem+ className="min-w-0 max-w-full"+ key={`field_option_${option}`}+ value={option}+ >+ <span className="block max-w-38 truncate">+ {option}+ </span>+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxPopup>+ </Combobox>) : (<Inputtype="text"- value={val}+ value={textVal}+ placeholder={field.defaultValue?.toString()}onChange={(e) =>handleLocalChange(field.id, e.target.value)}- onBlur={() => void handleSaveField(field.id, val)}+ onBlur={() =>+ void handleSaveField(field.id, textVal)+ }disabled={!canEdit}className="h-9 w-full bg-background text-sm"/>diff --git a/i18n/az-AZ.json b/i18n/az-AZ.jsonindex 03055aba5..b4c6c5e94 100644--- a/i18n/az-AZ.json+++ b/i18n/az-AZ.json@@ -1469,8 +1469,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2321,6 +2330,9 @@"error": "Failed to duplicate task","success": "Task duplicated successfully","titleSuffix": "{{title}} (copy)"+ },+ "customFields": {+ "ariaLabel": "Custom fields"}},"invitations": {diff --git a/i18n/de-DE.json b/i18n/de-DE.jsonindex 6156dc047..f10f631c6 100644--- a/i18n/de-DE.json+++ b/i18n/de-DE.json@@ -1549,8 +1549,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"security": "Security","securityPage": {@@ -2321,7 +2330,10 @@"descriptionSearchError": "Die Suche in Beschreibungen ist fehlgeschlagen. Ergebnisse sind möglicherweise unvollständig.","descriptionRetry": "Erneut versuchen","descriptionLoading": "Beschreibung wird geladen…",- "descriptionLoadError": "Die Beschreibung konnte nicht geladen werden. Versuche es erneut, um die aktuelle Version zu laden."+ "descriptionLoadError": "Die Beschreibung konnte nicht geladen werden. Versuche es erneut, um die aktuelle Version zu laden.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/el-GR.json b/i18n/el-GR.jsonindex c1a019779..9ed9c3996 100644--- a/i18n/el-GR.json+++ b/i18n/el-GR.json@@ -1469,8 +1469,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2321,7 +2330,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/en-US.json b/i18n/en-US.jsonindex 5672ea913..e2565bdf0 100644--- a/i18n/en-US.json+++ b/i18n/en-US.json@@ -1112,6 +1112,8 @@"noOptionsPlaceholder": "No options","defaultValuePlaceholder": "Default value","optionsPlaceholder": "Options separated by commas",+ "selectPlaceholder": "Select option(s)",+ "defaultValues": "{{count}} default(s)","required": "Required","addButton": "Add","creating": "Creating...",@@ -1124,13 +1126,20 @@"deleting": "Deleting...","deleteSuccess": "Custom field deleted.","deleteError": "Failed to delete custom field.",+ "reorderError": "Failed to reorder fields",+ "moreOptions": "+{{hiddenCount}} more",+ "clearDefault": "Clear",+ "options": "{{count}} option(s)",+ "availableOptions": "Available options","types": {"text": "Text","number": "Number","date": "Date","dropdown": "Dropdown",- "boolean": "Boolean"- }+ "boolean": "Boolean",+ "multiselect": "Multi-Select"+ },+ "multiple": "Multiple"},"githubIntegration": {"validation": {@@ -2317,6 +2326,9 @@"deleteTable": "Delete table"}},+ "customFields": {+ "ariaLabel": "Custom fields"+ },"descriptionSearchLoading": "Searching full descriptions…","descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry",diff --git a/i18n/es-ES.json b/i18n/es-ES.jsonindex 3a0324bc8..c4fa77bb8 100644--- a/i18n/es-ES.json+++ b/i18n/es-ES.json@@ -1470,8 +1470,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2329,7 +2338,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/fr-FR.json b/i18n/fr-FR.jsonindex 65b9ce5f2..c7ed16f79 100644--- a/i18n/fr-FR.json+++ b/i18n/fr-FR.json@@ -1448,30 +1448,39 @@"webhookPlaceholder": "https://your-mattermost-server.com/hooks/..."},"customFields": {- "addButton": "Add",- "createError": "Failed to create custom field.",- "createSuccess": "Custom field created.",- "creating": "Creating...",- "defaultLabel": "Default",- "defaultValuePlaceholder": "Default value",- "deleteButton": "Delete",- "deleteError": "Failed to delete custom field.",- "deleteSuccess": "Custom field deleted.",- "deleting": "Deleting...",- "empty": "No custom fields configured yet.",- "loading": "Loading custom fields...",- "namePlaceholder": "Field name",- "noOptionsPlaceholder": "No options",- "optionsPlaceholder": "Options separated by commas",- "required": "Required",- "typePlaceholder": "Select field type",+ "addButton": "Ajouter",+ "createError": "Échec de la création du champ personnalisé.",+ "createSuccess": "Champ personnalisé créé.",+ "creating": "Création...",+ "defaultLabel": "Par défaut",+ "defaultValuePlaceholder": "Valeur par défaut",+ "deleteButton": "Supprimer",+ "deleteError": "Échec de la suppression du champ personnalisé.",+ "deleteSuccess": "Champ personnalisé supprimé.",+ "deleting": "Suppression...",+ "empty": "Aucun champ personnalisé configuré pour le moment.",+ "loading": "Chargement...",+ "namePlaceholder": "Nom du champ",+ "noOptionsPlaceholder": "Aucune option",+ "optionsPlaceholder": "Options séparées par des virgules",+ "required": "Requis",+ "typePlaceholder": "Sélectionner un type de champ","types": {- "boolean": "Boolean",+ "boolean": "Booléen","date": "Date",- "dropdown": "Dropdown",- "number": "Number",- "text": "Text"- }+ "dropdown": "Sélecteur",+ "number": "Nombre",+ "text": "Texte",+ "multiselect": "Sélection multiple"+ },+ "availableOptions": "Options disponibles",+ "clearDefault": "Effacer",+ "defaultValues": "{{count}} par défaut",+ "moreOptions": "+{{hiddenCount}} de plus",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Échec du réagencement des champs",+ "selectPlaceholder": "Sélectionner une option"},"administration": "Administration","adminUsers": {@@ -2329,7 +2338,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/hi-IN.json b/i18n/hi-IN.jsonindex fef994b0b..9b98213e9 100644--- a/i18n/hi-IN.json+++ b/i18n/hi-IN.json@@ -1469,8 +1469,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2321,7 +2330,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/id-ID.json b/i18n/id-ID.jsonindex bf264756a..3030566c6 100644--- a/i18n/id-ID.json+++ b/i18n/id-ID.json@@ -1468,8 +1468,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2313,7 +2322,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/it-IT.json b/i18n/it-IT.jsonindex 869a9c5dc..0029d9278 100644--- a/i18n/it-IT.json+++ b/i18n/it-IT.json@@ -1470,8 +1470,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2329,7 +2338,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/ja-JP.json b/i18n/ja-JP.jsonindex 1ffcf22ed..b95ec7de0 100644--- a/i18n/ja-JP.json+++ b/i18n/ja-JP.json@@ -1468,8 +1468,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2313,6 +2322,9 @@"error": "Failed to duplicate task","success": "Task duplicated successfully","titleSuffix": "{{title}} (copy)"+ },+ "customFields": {+ "ariaLabel": "Custom fields"}},"invitations": {diff --git a/i18n/ko-KR.json b/i18n/ko-KR.jsonindex 99372dac8..548f66f32 100644--- a/i18n/ko-KR.json+++ b/i18n/ko-KR.json@@ -1468,8 +1468,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2313,7 +2322,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/mk-MK.json b/i18n/mk-MK.jsonindex 66136e7f8..fd0314a99 100644--- a/i18n/mk-MK.json+++ b/i18n/mk-MK.json@@ -1469,8 +1469,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2321,7 +2330,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/nl-NL.json b/i18n/nl-NL.jsonindex d5526b3c8..80c53f43b 100644--- a/i18n/nl-NL.json+++ b/i18n/nl-NL.json@@ -1469,8 +1469,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2321,7 +2330,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/pl-PL.json b/i18n/pl-PL.jsonindex 721138f58..20158b26b 100644--- a/i18n/pl-PL.json+++ b/i18n/pl-PL.json@@ -1949,8 +1949,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2519,6 +2528,9 @@"error": "Failed to duplicate task","success": "Task duplicated successfully","titleSuffix": "{{title}} (copy)"+ },+ "customFields": {+ "ariaLabel": "Custom fields"}},"press": {diff --git a/i18n/pt-BR.json b/i18n/pt-BR.jsonindex e155315d5..07a41ab6e 100644--- a/i18n/pt-BR.json+++ b/i18n/pt-BR.json@@ -1470,8 +1470,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2329,7 +2338,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/ru-RU.json b/i18n/ru-RU.jsonindex ddbf8353b..c3260dc09 100644--- a/i18n/ru-RU.json+++ b/i18n/ru-RU.json@@ -1479,8 +1479,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2393,7 +2402,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/tr-TR.json b/i18n/tr-TR.jsonindex c8461e639..ea7b8b4e1 100644--- a/i18n/tr-TR.json+++ b/i18n/tr-TR.json@@ -1469,8 +1469,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2321,7 +2330,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"pageTitle": "Davetler",diff --git a/i18n/uk-UA.json b/i18n/uk-UA.jsonindex 4ee7b6639..48c7dd17d 100644--- a/i18n/uk-UA.json+++ b/i18n/uk-UA.json@@ -1471,8 +1471,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2337,7 +2346,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/vi-VN.json b/i18n/vi-VN.jsonindex 73562f867..fb6a001d4 100644--- a/i18n/vi-VN.json+++ b/i18n/vi-VN.json@@ -1468,8 +1468,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2313,7 +2322,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/i18n/zh-CN.json b/i18n/zh-CN.jsonindex d4416d550..a0be88c9e 100644--- a/i18n/zh-CN.json+++ b/i18n/zh-CN.json@@ -1468,8 +1468,17 @@"date": "Date","dropdown": "Dropdown","number": "Number",- "text": "Text"- }+ "text": "Text",+ "multiselect": "Multi-Select"+ },+ "availableOptions": "Available options",+ "clearDefault": "Clear",+ "defaultValues": "{{count}} default(s)",+ "moreOptions": "+{{hiddenCount}} more",+ "multiple": "Multiple",+ "options": "{{count}} option(s)",+ "reorderError": "Failed to reorder fields",+ "selectPlaceholder": "Select option(s)"},"administration": "Administration","adminUsers": {@@ -2313,7 +2322,10 @@"descriptionSearchError": "Description search failed. Results may be incomplete.","descriptionRetry": "Retry","descriptionLoading": "Loading description…",- "descriptionLoadError": "The description could not be loaded. Retry to load the current version."+ "descriptionLoadError": "The description could not be loaded. Retry to load the current version.",+ "customFields": {+ "ariaLabel": "Custom fields"+ }},"invitations": {"email": {diff --git a/tests/api-integration/custom-field.test.ts b/tests/api-integration/custom-field.test.tsindex 147f55ba8..4ce4c4805 100644--- a/tests/api-integration/custom-field.test.ts+++ b/tests/api-integration/custom-field.test.ts@@ -152,6 +152,31 @@ describe("custom fields API", () => {expect(body).toContain("at least one option");});+ it("rejects a dropdown field with an empty options array", async () => {+ const { app, project } = await createFixture();++ const response = await app.request("/api/custom-field", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ projectId: project.id,+ name: "Environment",+ type: "dropdown",+ required: false,+ options: [],+ }),+ });++ const body = await response.text();+ expect(+ response.status,+ `Expected 400, got ${response.status}: ${body}`,+ ).toBe(400);+ expect(body).toContain("at least one option");+ });+it("rejects a required field without a default value", async () => {const { app, project } = await createFixture();@@ -394,4 +419,515 @@ describe("custom fields API", () => {).toBe(404);expect(responseBody).toContain("Custom field not found");});++ it("validates multiselect options", async () => {+ const { app, project } = await createFixture();++ const invalidDefinitions = [+ {+ options: undefined,+ expectedMessage: "at least 2 options",+ },+ {+ options: [],+ expectedMessage: "at least 2 options",+ },+ {+ options: ["only-one"],+ expectedMessage: "at least 2 options",+ },+ ];++ for (const definition of invalidDefinitions) {+ const response = await app.request("/api/custom-field", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ projectId: project.id,+ name: "Tags",+ type: "multiselect",+ required: false,+ ...(definition.options !== undefined+ ? { options: definition.options }+ : {}),+ }),+ });++ const body = await response.text();++ expect(+ response.status,+ `Expected 400, got ${response.status}: ${body}`,+ ).toBe(400);++ expect(body).toContain(definition.expectedMessage);+ }+ });++ it("rejects invalid multiselect defaults before persisting the field", async () => {+ const { app, project } = await createFixture();++ for (const required of [false, true]) {+ const invalidDefaults = [+ "not-json",+ "{}",+ "null",+ '"frontend"',+ '["unknown"]',+ "[1]",+ "[{}]",+ ];+ if (required) invalidDefaults.push("[]");++ for (const defaultValue of invalidDefaults) {+ const response = await app.request("/api/custom-field", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ projectId: project.id,+ name: "Category",+ type: "multiselect",+ required,+ options: ["frontend", "backend"],+ defaultValue,+ }),+ });+ expect(response.status, await response.text()).toBe(400);+ }+ }++ const fields = await db+ .select()+ .from(schema.customFieldDefinitionTable)+ .where(eq(schema.customFieldDefinitionTable.projectId, project.id));+ expect(fields).toEqual([]);+ });++ it("validates optional multiselect task values while allowing empty selections", async () => {+ const { app, project } = await createFixture();+ const fieldResponse = await app.request("/api/custom-field", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ projectId: project.id,+ name: "Category",+ type: "multiselect",+ required: false,+ options: ["frontend", "backend"],+ defaultValue: "[]",+ }),+ });+ expect(fieldResponse.status).toBe(200);+ const field = await fieldResponse.json();+ const status = await getProjectStatus(project.id);++ for (const value of [+ "not-json",+ "{}",+ "null",+ '"frontend"',+ '["unknown"]',+ "[1]",+ "[{}]",+ ]) {+ const response = await app.request(`/api/task/${project.id}`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ title: "Invalid multiselect task",+ description: "",+ status,+ priority: "no-priority",+ customFields: [{ fieldId: field.id, value }],+ }),+ });+ expect(response.status, await response.text()).toBe(400);+ }++ const tasks = await db+ .select()+ .from(schema.taskTable)+ .where(eq(schema.taskTable.projectId, project.id));+ expect(tasks).toEqual([]);++ for (const value of ["", "[]", '["frontend"]']) {+ const response = await app.request(`/api/task/${project.id}`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ title: "Valid multiselect task",+ description: "",+ status,+ priority: "no-priority",+ customFields: [{ fieldId: field.id, value }],+ }),+ });+ expect(response.status, await response.text()).toBe(200);+ }+ });++ it("creates a multiselect field with options and applies its default to existing tasks", async () => {+ const { app, project } = await createFixture();++ const status = await getProjectStatus(project.id);++ const taskResponse = await app.request(`/api/task/${project.id}`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ title: "Existing task",+ description: "",+ status,+ priority: "no-priority",+ }),+ });++ const taskBody = await taskResponse.text();++ expect(taskResponse.status, `Task creation failed: ${taskBody}`).toBe(200);++ const task = JSON.parse(taskBody);+ const defaultValue = JSON.stringify(["frontend", "backend"]);++ const fieldResponse = await app.request("/api/custom-field", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ projectId: project.id,+ name: "Tags",+ type: "multiselect",+ required: false,+ options: ["frontend", "backend", "infra"],+ defaultValue,+ }),+ });++ const fieldBody = await fieldResponse.text();++ expect(fieldResponse.status, `Field creation failed: ${fieldBody}`).toBe(+ 200,+ );++ const field = JSON.parse(fieldBody);++ const valuesResponse = await app.request(+ `/api/custom-field/task/${task.id}`,+ );++ const valuesBody = await valuesResponse.text();++ expect(valuesResponse.status, `Get values failed: ${valuesBody}`).toBe(200);++ const values = JSON.parse(valuesBody);++ expect(values).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ taskId: task.id,+ fieldId: field.id,+ value: defaultValue,+ fieldType: "multiselect",+ }),+ ]),+ );+ });++ it("creates a task with an explicit multiselect value", async () => {+ const { app, project } = await createFixture();++ const fieldResponse = await app.request("/api/custom-field", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ projectId: project.id,+ name: "Tags",+ type: "multiselect",+ required: false,+ options: ["frontend", "backend", "infra"],+ }),+ });++ const fieldBody = await fieldResponse.text();++ expect(fieldResponse.status, `Field creation failed: ${fieldBody}`).toBe(+ 200,+ );++ const field = JSON.parse(fieldBody);+ const status = await getProjectStatus(project.id);+ const selectedValue = JSON.stringify(["infra"]);++ const taskResponse = await app.request(`/api/task/${project.id}`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ title: "Task with multiselect",+ description: "",+ status,+ priority: "no-priority",+ customFields: [+ {+ fieldId: field.id,+ value: selectedValue,+ },+ ],+ }),+ });++ const taskBody = await taskResponse.text();++ expect(taskResponse.status, `Task creation failed: ${taskBody}`).toBe(200);++ const task = JSON.parse(taskBody);++ const valuesResponse = await app.request(+ `/api/custom-field/task/${task.id}`,+ );++ const valuesBody = await valuesResponse.text();++ expect(valuesResponse.status, `Get values failed: ${valuesBody}`).toBe(200);++ const values = JSON.parse(valuesBody);++ expect(values).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ taskId: task.id,+ fieldId: field.id,+ value: selectedValue,+ fieldType: "multiselect",+ }),+ ]),+ );+ });++ it("uses the default for required fields and rejects an explicit empty value", async () => {+ const { app, project } = await createFixture();++ const defaultValue = JSON.stringify(["frontend"]);++ const fieldResponse = await app.request("/api/custom-field", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ projectId: project.id,+ name: "Category",+ type: "multiselect",+ required: true,+ options: ["frontend", "backend"],+ defaultValue,+ }),+ });++ const fieldBody = await fieldResponse.text();++ expect(fieldResponse.status, `Field creation failed: ${fieldBody}`).toBe(+ 200,+ );++ const field = JSON.parse(fieldBody);+ const status = await getProjectStatus(project.id);++ const defaultTaskResponse = await app.request(`/api/task/${project.id}`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ title: "Task using default",+ description: "",+ status,+ priority: "no-priority",+ }),+ });++ const defaultTaskBody = await defaultTaskResponse.text();++ expect(+ defaultTaskResponse.status,+ `Task creation failed: ${defaultTaskBody}`,+ ).toBe(200);++ const defaultTask = JSON.parse(defaultTaskBody);++ const defaultValuesResponse = await app.request(+ `/api/custom-field/task/${defaultTask.id}`,+ );++ const defaultValuesBody = await defaultValuesResponse.text();++ expect(defaultValuesResponse.status).toBe(200);++ const defaultValues = JSON.parse(defaultValuesBody);++ expect(defaultValues).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ fieldId: field.id,+ value: defaultValue,+ }),+ ]),+ );++ const invalidTaskResponse = await app.request(`/api/task/${project.id}`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ title: "Task with empty required value",+ description: "",+ status,+ priority: "no-priority",+ customFields: [+ {+ fieldId: field.id,+ value: "[]",+ },+ ],+ }),+ });++ const invalidTaskBody = await invalidTaskResponse.text();++ expect(+ invalidTaskResponse.status,+ `Expected 400, got ${invalidTaskResponse.status}: ${invalidTaskBody}`,+ ).toBe(400);++ expect(invalidTaskBody).toContain("required");+ });++ it("updates, clears, and validates a multiselect value", async () => {+ const { app, project } = await createFixture();++ const fieldResponse = await app.request("/api/custom-field", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ projectId: project.id,+ name: "Tags",+ type: "multiselect",+ required: false,+ options: ["alpha", "beta", "gamma"],+ }),+ });++ const fieldBody = await fieldResponse.text();++ expect(fieldResponse.status, `Field creation failed: ${fieldBody}`).toBe(+ 200,+ );++ const field = JSON.parse(fieldBody);+ const status = await getProjectStatus(project.id);++ const taskResponse = await app.request(`/api/task/${project.id}`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ title: "Multiselect task",+ description: "",+ status,+ priority: "no-priority",+ }),+ });++ const taskBody = await taskResponse.text();++ expect(taskResponse.status, `Task creation failed: ${taskBody}`).toBe(200);++ const task = JSON.parse(taskBody);++ const updateValue = async (value: string) => {+ return app.request("/api/custom-field/value", {+ method: "PUT",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ taskId: task.id,+ fieldId: field.id,+ value,+ }),+ });+ };++ const updateValueResponse = await updateValue(+ JSON.stringify(["beta", "gamma"]),+ );++ const updateValueBody = await updateValueResponse.text();++ expect(+ updateValueResponse.status,+ `Update failed: ${updateValueBody}`,+ ).toBe(200);++ const valuesResponse = await app.request(+ `/api/custom-field/task/${task.id}`,+ );++ const valuesBody = await valuesResponse.text();++ expect(valuesResponse.status, `Get values failed: ${valuesBody}`).toBe(200);++ const values = JSON.parse(valuesBody);++ expect(values).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ fieldId: field.id,+ value: JSON.stringify(["beta", "gamma"]),+ fieldType: "multiselect",+ }),+ ]),+ );++ const clearResponse = await updateValue("");+ const clearBody = await clearResponse.text();++ expect(clearResponse.status, `Clear failed: ${clearBody}`).toBe(200);++ const invalidJsonResponse = await updateValue("alpha");+ const invalidJsonBody = await invalidJsonResponse.text();++ expect(+ invalidJsonResponse.status,+ `Expected 400, got ${invalidJsonResponse.status}: ${invalidJsonBody}`,+ ).toBe(400);++ expect(invalidJsonBody).toContain("JSON array");++ const invalidOptionResponse = await updateValue(+ JSON.stringify(["alpha", "unknown"]),+ );+ const invalidOptionBody = await invalidOptionResponse.text();++ expect(+ invalidOptionResponse.status,+ `Expected 400, got ${invalidOptionResponse.status}: ${invalidOptionBody}`,+ ).toBe(400);++ expect(invalidOptionBody).toContain(+ "Invalid option(s) for this custom field",+ );+ });});