diff --git a/apps/web/app/api/domains/route.ts b/apps/web/app/api/domains/route.ts index eadc193..6dbd8cb 100644 --- a/apps/web/app/api/domains/route.ts +++ b/apps/web/app/api/domains/route.ts @@ -11,7 +11,7 @@ import { z } from 'zod'; const createDomainSchema = z.object({ name: z.string().min(1, 'Name is required'), - slug: z.string().min(1, 'Slug is required'), + slug: z.string().min(1).optional(), color: z.string().optional().nullable(), icon: z.string().optional().nullable(), parentId: z.string().uuid().optional().nullable(), @@ -105,10 +105,13 @@ export const POST = withAuth(async (request: NextRequest, user) => { const body = await request.json(); const data = createDomainSchema.parse(body); + // Auto-generate slug from name if not provided + const slug = data.slug || data.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, '') || 'domain'; + const [domain] = await db.insert(domains) .values({ name: data.name, - slug: data.slug, + slug, color: data.color || null, icon: data.icon || null, parentId: data.parentId || null, diff --git a/apps/web/components/settings/settings-domains.tsx b/apps/web/components/settings/settings-domains.tsx index fe60472..4d7b96a 100644 --- a/apps/web/components/settings/settings-domains.tsx +++ b/apps/web/components/settings/settings-domains.tsx @@ -203,7 +203,7 @@ export function SettingsDomains() { {/* Add new domain */} -
+
@@ -226,7 +226,7 @@ export function SettingsDomains() { disabled={creating} />
- diff --git a/apps/web/components/topbar.tsx b/apps/web/components/topbar.tsx index d243f2d..a790796 100644 --- a/apps/web/components/topbar.tsx +++ b/apps/web/components/topbar.tsx @@ -17,9 +17,11 @@ export function TopBar() { if (pathname.startsWith('/projects')) openCreate('project'); else if (pathname.startsWith('/habits')) openCreate('habit'); else if (pathname.startsWith('/tasks')) openCreate('task'); - else { - document.dispatchEvent(new KeyboardEvent('keydown', { key: 'k', metaKey: true })); - } + // On other pages (e.g. /settings) the topbar's "Quick add" button + // visually overlaps form action buttons (e.g. Domain "Add") because + // both are anchored top-right. Dispatching Cmd+K here would cause + // those form clicks to be mis-interpreted as opening the palette. + // So we no-op on those pages — the form buttons handle their own actions. } const label = pathname.startsWith('/projects') ? 'New project' @@ -39,10 +41,14 @@ export function TopBar() {
- + {(pathname.startsWith('/projects') || + pathname.startsWith('/habits') || + pathname.startsWith('/tasks')) && ( + + )}