⚡ 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
fix(custom-fields): preserve legacy defaults and name-only edits
Tinb2300516c839
diff --git a/apps/web/src/components/project/edit-custom-field-dialog.test.tsx b/apps/web/src/components/project/edit-custom-field-dialog.test.tsxindex ae7fff625..9f5ee892d 100644--- a/apps/web/src/components/project/edit-custom-field-dialog.test.tsx+++ b/apps/web/src/components/project/edit-custom-field-dialog.test.tsx@@ -71,6 +71,29 @@ describe("edit custom field dialog", () => {},});});+ it("allows name-only edits of legacy labels without rewriting their identities", async () => {+ const onClose = vi.fn();+ mutateAsync.mockResolvedValue({});+ render(+ <EditCustomFieldDialog+ field={{ ...field, options: ["Alice", " Alice ", "Bob"] }}+ onClose={onClose}+ />,+ );+ fireEvent.change(+ screen.getByLabelText("settings:customFields.namePlaceholder"),+ { target: { value: "Attendees" } },+ );+ fireEvent.click(+ screen.getByRole("button", { name: "settings:customFields.saveButton" }),+ );+ await waitFor(() => expect(onClose).toHaveBeenCalled());+ expect(mutateAsync).toHaveBeenCalledWith({+ param: { id: "field" },+ json: { name: "Attendees", updatedAt: field.updatedAt },+ });+ });+it("cancels without saving", () => {const onClose = vi.fn();render(<EditCustomFieldDialog field={field} onClose={onClose} />);diff --git a/apps/web/src/components/project/edit-custom-field-dialog.tsx b/apps/web/src/components/project/edit-custom-field-dialog.tsxindex c843bca27..d3c11ba49 100644--- a/apps/web/src/components/project/edit-custom-field-dialog.tsx+++ b/apps/web/src/components/project/edit-custom-field-dialog.tsx@@ -37,10 +37,20 @@ export default function EditCustomFieldDialog({const [error, setError] = useState<string | null>(null);const { mutateAsync, isPending } = useUpdateCustomField();const hasOptions = field.type === "dropdown" || field.type === "multiselect";+ const optionsChanged =+ options.length !== (field.options?.length ?? 0) ||+ options.some(+ (option, index) =>+ option.originalValue !== field.options?.[index] ||+ option.value !== field.options?.[index] ||+ option.hidden !==+ (field.hiddenOptions ?? []).includes(option.originalValue ?? ""),+ );const normalizedOptions = options.map((option) => option.value.trim());const valid =name.trim() &&(!hasOptions ||+ !optionsChanged ||(options.length >= (field.type === "multiselect" ? 2 : 1) &&normalizedOptions.every(Boolean) &&new Set(normalizedOptions).size === options.length &&@@ -55,7 +65,7 @@ export default function EditCustomFieldDialog({json: {name: name.trim(),updatedAt: field.updatedAt,- ...(hasOptions+ ...(hasOptions && optionsChanged? {options: options.map(({ originalValue, value, hidden }) => ({originalValue,diff --git a/apps/web/src/components/shared/modals/create-task-modal.test.tsx b/apps/web/src/components/shared/modals/create-task-modal.test.tsxindex 663b64131..6d262b7eb 100644--- a/apps/web/src/components/shared/modals/create-task-modal.test.tsx+++ b/apps/web/src/components/shared/modals/create-task-modal.test.tsx@@ -276,6 +276,38 @@ describe("CreateTaskModal", () => {},);+ it.each([false, true])(+ "applies legacy padded dropdown defaults (required: %s)",+ async (required) => {+ useLocation.mockReturnValue({+ pathname: "/dashboard/workspace/workspace-1/project/project-1/board",+ });+ customFields = [+ {+ id: "people",+ name: "People",+ type: "dropdown",+ options: ["Alice", "Bob"],+ hiddenOptions: [],+ defaultValue: " Alice ",+ required,+ },+ ];+ render(<CreateTaskModal open onClose={vi.fn()} />, {+ wrapper: createWrapper(),+ });+ enterTitle();+ await act(async () => {+ submit();+ });+ expect(createTask).toHaveBeenCalledWith(+ expect.objectContaining({+ customFields: [{ fieldId: "people", value: "Alice" }],+ }),+ );+ },+ );+it("keeps unsaved input while discard confirmation is open", async () => {useLocation.mockReturnValue({pathname: "/dashboard/workspace/workspace-1/project/project-1/board",diff --git a/apps/web/src/components/shared/modals/create-task-modal.tsx b/apps/web/src/components/shared/modals/create-task-modal.tsxindex 87b8f7f28..06d6d5d1a 100644--- a/apps/web/src/components/shared/modals/create-task-modal.tsx+++ b/apps/web/src/components/shared/modals/create-task-modal.tsx@@ -318,8 +318,11 @@ function CreateTaskModalContent({const visibleOptions = (field.options ?? []).filter((option) => !hidden.includes(option),);- if (field.type === "dropdown" && !visibleOptions.includes(value)) {- value = "";+ if (field.type === "dropdown") {+ value = visibleOptions.includes(value)+ ? value+ : (visibleOptions.find((option) => option === value.trim()) ??+ "");} else if (field.type === "multiselect" && value) {try {const selected: unknown = JSON.parse(value);