From 6b98da54bd0ffef97dee6be505a77dd514a6f582 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 26 Feb 2026 18:03:10 -0500 Subject: [PATCH] fix: Collection overview edit state (#11586) --- app/scenes/Collection/components/Header.tsx | 33 +++++++++++++++++++-- app/scenes/Collection/index.tsx | 9 ++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/app/scenes/Collection/components/Header.tsx b/app/scenes/Collection/components/Header.tsx index 44a2deb601..31f3d99726 100644 --- a/app/scenes/Collection/components/Header.tsx +++ b/app/scenes/Collection/components/Header.tsx @@ -3,7 +3,9 @@ import breakpoint from "styled-components-breakpoint"; import first from "lodash/first"; import { Suspense, useCallback } from "react"; import styled from "styled-components"; +import { CollectionValidation } from "@shared/validations"; import Heading from "~/components/Heading"; +import ContentEditable from "~/components/ContentEditable"; import CollectionIcon from "~/components/Icons/CollectionIcon"; import type Collection from "~/models/Collection"; import { colorPalette } from "@shared/utils/collections"; @@ -16,16 +18,32 @@ const IconPicker = lazyWithRetry(() => import("~/components/IconPicker")); type Props = { /** The collection for which to render a header */ collection: Collection; + /** Whether the header is in editing mode */ + isEditing?: boolean; }; -export const Header = observer(function Header_({ collection }: Props) { +export const Header = observer(function Header_({ + collection, + isEditing, +}: Props) { const can = usePolicy(collection); + const canEdit = can.update && isEditing; const handleIconChange = useCallback( (icon: string | null, color: string | null) => collection?.save({ icon, color }), [collection] ); + const handleTitleChange = useCallback( + (text: string) => { + const trimmed = text.trim(); + if (trimmed.length > 0 && trimmed !== collection.name) { + void collection.save({ name: trimmed }); + } + }, + [collection] + ); + const fallbackIcon = collection ? ( ) : null; @@ -33,7 +51,7 @@ export const Header = observer(function Header_({ collection }: Props) { return ( - {can.update ? ( + {canEdit ? ( - {collection.name} + {canEdit ? ( + + ) : ( + collection.name + )} ); }); diff --git a/app/scenes/Collection/index.tsx b/app/scenes/Collection/index.tsx index 8834bbe62c..16e58eb793 100644 --- a/app/scenes/Collection/index.tsx +++ b/app/scenes/Collection/index.tsx @@ -176,7 +176,10 @@ const CollectionScene = observer(function CollectionScene_() { > -
+
) : (