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_() {
>
-
+
) : (