Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

fix(web): reach every new issue body section from a dropdown (#85)

Croff1d13b6dbb8e9
diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css
index 870a305a..9e6a1ae8 100644
--- a/apps/web/src/app/globals.css
+++ b/apps/web/src/app/globals.css
@@ -103,6 +103,8 @@
--kanban-card: oklch(0.965 0 0);
--kanban-card-hover: oklch(0.94 0 0);
--kanban-card-selected: oklch(0.925 0.04 265);
+ --overlay-shadow: 0 12px 28px -8px rgb(0 0 0 / 0.18), 0 4px 10px -4px rgb(0 0 0 / 0.1);
+ --modal-shadow: 0 32px 64px -16px rgb(0 0 0 / 0.28), 0 12px 24px -12px rgb(0 0 0 / 0.16);
}
.dark {
@@ -144,6 +146,30 @@
--kanban-card: oklch(0.195 0 0);
--kanban-card-hover: oklch(0.235 0 0);
--kanban-card-selected: oklch(0.31 0.07 266);
+ --overlay-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.7), 0 6px 16px -6px rgb(0 0 0 / 0.55);
+ --modal-shadow: 0 40px 80px -20px rgb(0 0 0 / 0.85), 0 16px 32px -16px rgb(0 0 0 / 0.7);
+}
+
+/* Every floating surface lifts off the page with the same shadow. It is set here
+ rather than per component: the shadcn components are kept as generated, and
+ `shadow-md` on a popover reads as nothing against a background of nearly the
+ same lightness. These rules sit outside @layer, so they win over the utility. */
+[data-slot='dropdown-menu-content'],
+[data-slot='dropdown-menu-sub-content'],
+[data-slot='context-menu-content'],
+[data-slot='context-menu-sub-content'],
+[data-slot='select-content'],
+[data-slot='popover-content'],
+[data-slot='combobox-content'],
+[data-slot='tooltip-content'] {
+ box-shadow: var(--overlay-shadow);
+}
+
+/* Dialogs and sheets cover a far larger area, so they carry a wider, deeper cast
+ than a menu. */
+[data-slot='dialog-content'],
+[data-slot='sheet-content'] {
+ box-shadow: var(--modal-shadow);
}
/* Kanban card surface — darker than the modal/detail --card, and it changes
diff --git a/apps/web/src/features/issue/components/create/NewIssueBody.tsx b/apps/web/src/features/issue/components/create/NewIssueBody.tsx
index 45ab301e..e40e1706 100644
--- a/apps/web/src/features/issue/components/create/NewIssueBody.tsx
+++ b/apps/web/src/features/issue/components/create/NewIssueBody.tsx
@@ -1,20 +1,21 @@
import { type Editor } from '@tiptap/react';
import { type CustomField, type IssueFieldValueInput } from '@/lib/api';
import { cn } from '@/lib/utils';
-import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { type Embeddable } from '../../utils/attachmentEmbed';
-import { DESCRIPTION_TAB, OTHER_TAB, fieldTab } from '../../utils/bodyTabs';
+import { DESCRIPTION_SECTION, OTHER_SECTION, fieldSection } from '../../utils/bodySections';
+import { hasFieldValue } from '../../utils/fieldValues';
import IssueMarkdownEditor from '../editor/IssueMarkdownEditor';
import NewIssueBodyFields from './NewIssueBodyFields';
+import NewIssueBodySwitcher from './NewIssueBodySwitcher';
// The written part of a new issue: the description, plus the custom fields the
-// project shows in the body. Each markdown field gets its own tab so only one
-// editor is on screen at a time — otherwise they stack up and the dialog turns
-// into one long scroll. Every tab stays mounted (forceMount), so switching away
-// keeps the editor instance the modal needs to strip an attachment's embeds.
+// project shows in the body. A switcher keeps one markdown field on screen at a
+// time — otherwise the editors stack up and the dialog turns into one long
+// scroll. The hidden sections stay mounted, so switching away keeps the editor
+// instance the modal needs to strip an attachment's embeds.
export default function NewIssueBody({
- tab,
- onTabChange,
+ section,
+ onSectionChange,
fullscreen,
description,
onDescriptionChange,
@@ -26,9 +27,9 @@ export default function NewIssueBody({
uploadFile,
}: {
// Held by the modal: it inserts an attachment into whichever editor is on
- // screen, so it has to know which tab that is.
- tab: string;
- onTabChange: (tab: string) => void;
+ // screen, so it has to know which section that is.
+ section: string;
+ onSectionChange: (section: string) => void;
fullscreen: boolean;
description: string;
onDescriptionChange: (markdown: string) => void;
@@ -58,35 +59,43 @@ export default function NewIssueBody({
if (bodyDefs.length === 0) return descriptionEditor;
- // No flex-1 in compact: the tab is sized by its content there, but min-h-0
+ const sections = [
+ { value: DESCRIPTION_SECTION, label: 'Description', filled: description.trim() !== '' },
+ ...markdownDefs.map((def) => ({
+ value: fieldSection(def.id),
+ label: def.name,
+ filled: hasFieldValue(fieldValues[def.id]),
+ })),
+ ...(pillDefs.length > 0
+ ? [
+ {
+ value: OTHER_SECTION,
+ label: 'Other',
+ filled: pillDefs.some((def) => hasFieldValue(fieldValues[def.id])),
+ },
+ ]
+ : []),
+ ];
+
+ // Changing the issue type swaps the body fields, which can leave the selected
+ // section pointing at one that is gone.
+ const active = sections.some((s) => s.value === section) ? section : DESCRIPTION_SECTION;
+
+ // No flex-1 in compact: the section is sized by its content there, but min-h-0
// still lets it give height back once the dialog runs out of it.
- const contentClass = cn(
- 'flex min-h-0 flex-col data-[state=inactive]:hidden',
- fullscreen && 'flex-1',
- );
+ const sectionClass = (value: string) =>
+ cn('flex min-h-0 flex-col', fullscreen && 'flex-1', value !== active && 'hidden');
return (
- <Tabs
- value={tab}
- onValueChange={onTabChange}
- className={cn('mt-3 flex min-h-0 flex-col', fullscreen && 'flex-1')}
- >
- <TabsList variant="line" className="shrink-0">
- <TabsTrigger value={DESCRIPTION_TAB}>Description</TabsTrigger>
- {markdownDefs.map((def) => (
- <TabsTrigger key={def.id} value={fieldTab(def.id)}>
- {def.name}
- </TabsTrigger>
- ))}
- {pillDefs.length > 0 && <TabsTrigger value={OTHER_TAB}>Other</TabsTrigger>}
- </TabsList>
+ <div className={cn('mt-3 flex min-h-0 flex-col gap-1.5', fullscreen && 'flex-1')}>
+ <div className="flex shrink-0 items-center">
+ <NewIssueBodySwitcher sections={sections} value={active} onChange={onSectionChange} />
+ </div>
- <TabsContent value={DESCRIPTION_TAB} forceMount className={contentClass}>
- {descriptionEditor}
- </TabsContent>
+ <div className={sectionClass(DESCRIPTION_SECTION)}>{descriptionEditor}</div>
{markdownDefs.map((def) => (
- <TabsContent key={def.id} value={fieldTab(def.id)} forceMount className={contentClass}>
+ <div key={def.id} className={sectionClass(fieldSection(def.id))}>
<IssueMarkdownEditor
className={editorClass}
defaultValue={(fieldValues[def.id]?.value as string) ?? ''}
@@ -95,14 +104,14 @@ export default function NewIssueBody({
onReady={(editor) => onFieldEditorReady(def.id, editor)}
uploadFile={uploadFile}
/>
- </TabsContent>
+ </div>
))}
{pillDefs.length > 0 && (
- <TabsContent value={OTHER_TAB} className={cn(contentClass, 'overflow-y-auto')}>
+ <div className={cn(sectionClass(OTHER_SECTION), 'overflow-y-auto')}>
<NewIssueBodyFields defs={pillDefs} values={fieldValues} onChange={onFieldValue} />
- </TabsContent>
+ </div>
)}
- </Tabs>
+ </div>
);
}
diff --git a/apps/web/src/features/issue/components/create/NewIssueBodyFields.tsx b/apps/web/src/features/issue/components/create/NewIssueBodyFields.tsx
index 33aa6972..834381d6 100644
--- a/apps/web/src/features/issue/components/create/NewIssueBodyFields.tsx
+++ b/apps/web/src/features/issue/components/create/NewIssueBodyFields.tsx
@@ -1,8 +1,8 @@
import { type CustomField, type IssueFieldValueInput } from '@/lib/api';
import IssueCustomFieldPill from '../fields/IssueCustomFieldPill';
-// The body fields that are not markdown, gathered in the "Other" tab: a pill each
-// is too small to be worth a tab of its own.
+// The body fields that are not markdown, gathered in the "Other" section: a pill
+// each is too small to be worth a section of its own.
export default function NewIssueBodyFields({
defs,
values,
diff --git a/apps/web/src/features/issue/components/create/NewIssueBodySwitcher.tsx b/apps/web/src/features/issue/components/create/NewIssueBodySwitcher.tsx
new file mode 100644
index 00000000..ac989aca
--- /dev/null
+++ b/apps/web/src/features/issue/components/create/NewIssueBodySwitcher.tsx
@@ -0,0 +1,53 @@
+import { Check, ChevronDown } from 'lucide-react';
+import { cn } from '@/lib/utils';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+
+// Picks the part of the new issue body that is on screen. A dropdown rather than
+// a row of tabs: a project can define enough body fields that the row runs past
+// the dialog edge, and the ones past it cannot be reached.
+export default function NewIssueBodySwitcher({
+ sections,
+ value,
+ onChange,
+}: {
+ sections: { value: string; label: string; filled: boolean }[];
+ value: string;
+ onChange: (section: string) => void;
+}) {
+ const active = sections.find((s) => s.value === value);
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ {/* Kept quiet on purpose: the dialog title is the only heading that
+ carries weight here. No padding either, so the label starts on the
+ same line as the editor text under it. */}
+ <button
+ type="button"
+ className="flex h-6 max-w-full min-w-0 items-center gap-1 text-xs font-medium tracking-wide text-muted-foreground uppercase transition-colors hover:text-foreground"
+ >
+ <span className="truncate">{active?.label}</span>
+ <ChevronDown className="size-3.5 shrink-0" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="max-h-72 w-56 overflow-y-auto">
+ {/* The check marks a section that has been written in, so the open one is
+ marked by its background instead. */}
+ {sections.map((s) => (
+ <DropdownMenuItem
+ key={s.value}
+ onClick={() => onChange(s.value)}
+ className={cn(s.value === value && 'bg-accent/50')}
+ >
+ <span className="min-w-0 flex-1 truncate">{s.label}</span>
+ {s.filled && <Check className="size-4 shrink-0 text-green-500" />}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
diff --git a/apps/web/src/features/issue/components/create/NewIssueModal.tsx b/apps/web/src/features/issue/components/create/NewIssueModal.tsx
index d18a9356..354951da 100644
--- a/apps/web/src/features/issue/components/create/NewIssueModal.tsx
+++ b/apps/web/src/features/issue/components/create/NewIssueModal.tsx
@@ -16,7 +16,8 @@ import {
stripEmbed,
type Embeddable,
} from '../../utils/attachmentEmbed';
-import { DESCRIPTION_TAB, OTHER_TAB, fieldTabId } from '../../utils/bodyTabs';
+import { DESCRIPTION_SECTION, OTHER_SECTION, fieldSectionId } from '../../utils/bodySections';
+import { hasFieldValue } from '../../utils/fieldValues';
import IssueCustomFieldPill from '../fields/IssueCustomFieldPill';
import NewIssueAttachButton from './NewIssueAttachButton';
import NewIssueAttachmentStrip from './NewIssueAttachmentStrip';
@@ -86,7 +87,7 @@ export default function NewIssueModal({
const [fullscreen, setFullscreen] = useState(false);
// Custom fields for the selected type (global + type-scoped). Fields flagged
- // "show in main info" get their own body tab; the rest are added on demand from
+ // "show in main info" get their own body section; the rest are added on demand from
// the "…" menu.
const fieldsQuery = useCustomFieldsQuery(project.project.key, typeId ?? undefined);
const fieldDefs = fieldsQuery.data ?? [];
@@ -107,13 +108,13 @@ export default function NewIssueModal({
// from the strip takes its embeds with it wherever they were inserted.
const fieldEditors = useRef(new Map<number, Editor>());
- // Which of the body tabs is open, so an attachment lands in the editor the user
- // is looking at.
- const [bodyTab, setBodyTab] = useState(DESCRIPTION_TAB);
+ // Which of the body sections is open, so an attachment lands in the editor the
+ // user is looking at.
+ const [bodySection, setBodySection] = useState(DESCRIPTION_SECTION);
function activeBodyEditor(): Editor | null {
- if (bodyTab === DESCRIPTION_TAB) return descEditor;
- const fieldId = fieldTabId(bodyTab);
+ if (bodySection === DESCRIPTION_SECTION) return descEditor;
+ const fieldId = fieldSectionId(bodySection);
return fieldId === null ? null : (fieldEditors.current.get(fieldId) ?? null);
}
@@ -163,7 +164,7 @@ export default function NewIssueModal({
const insertFilesRef = useRef(insertFilesIntoBody);
insertFilesRef.current = insertFilesIntoBody;
- // A paste carrying files lands in the open tab's editor unless a markdown editor
+ // A paste carrying files lands in the open section's editor unless a markdown editor
// has the focus, in which case tiptap has already inserted it there. The listener
// is on the document because the focus may sit on the dialog itself, above the
// modal body.
@@ -246,9 +247,7 @@ export default function NewIssueModal({
for (const def of fieldDefs) {
if (!def.showInBody && !activeFieldIds.includes(def.id)) continue;
const v = fieldValues[def.id];
- if (!v) continue;
- const hasValue = (v.optionIds?.length ?? 0) > 0 || (v.value != null && v.value !== '');
- if (!hasValue) continue;
+ if (!hasFieldValue(v)) continue;
const value = typeof v.value === 'string' ? { ...v, value: rewrite(v.value) } : v;
await setFieldValueMutation.mutateAsync({ issueId: created.id, fieldId: def.id, value });
}
@@ -288,11 +287,11 @@ export default function NewIssueModal({
/>
{/* The written content is the one part that gives up height, so the pills
and the footer stay in view however much of it there is. It scrolls
- inside its editors, not here, which keeps the tab bar in place. */}
+ inside its editors, not here, which keeps the switcher in place. */}
<div className={cn('flex min-h-0 flex-col overflow-hidden', fullscreen && 'flex-1')}>
<NewIssueBody
- tab={bodyTab}
- onTabChange={setBodyTab}
+ section={bodySection}
+ onSectionChange={setBodySection}
fullscreen={fullscreen}
description={description}
onDescriptionChange={setDescription}
@@ -419,7 +418,7 @@ export default function NewIssueModal({
<NewIssueAttachButton onPick={attachments.attach} />
<NewIssueAttachmentStrip
items={attachments.pending}
- onInsert={bodyTab === OTHER_TAB ? undefined : insertIntoBody}
+ onInsert={bodySection === OTHER_SECTION ? undefined : insertIntoBody}
onAnnotate={annotateAttachment}
onRemove={removeAttachment}
/>
diff --git a/apps/web/src/features/issue/utils/bodySections.ts b/apps/web/src/features/issue/utils/bodySections.ts
new file mode 100644
index 00000000..0eeb186a
--- /dev/null
+++ b/apps/web/src/features/issue/utils/bodySections.ts
@@ -0,0 +1,17 @@
+// The sections of the new issue body. The modal reads them back to find the
+// editor an attachment should be inserted into, so the two sides share them
+// instead of each spelling the strings out.
+export const DESCRIPTION_SECTION = 'description';
+
+// Holds the body fields that are not markdown, so it has no editor.
+export const OTHER_SECTION = 'other';
+
+const FIELD_SECTION_PREFIX = 'field-';
+
+export const fieldSection = (fieldId: number) => `${FIELD_SECTION_PREFIX}${fieldId}`;
+
+export function fieldSectionId(section: string): number | null {
+ if (!section.startsWith(FIELD_SECTION_PREFIX)) return null;
+ const id = Number(section.slice(FIELD_SECTION_PREFIX.length));
+ return Number.isNaN(id) ? null : id;
+}
diff --git a/apps/web/src/features/issue/utils/bodyTabs.ts b/apps/web/src/features/issue/utils/bodyTabs.ts
deleted file mode 100644
index 8efb2cf0..00000000
--- a/apps/web/src/features/issue/utils/bodyTabs.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-// The tab values of the new issue body. The modal reads them back to find the
-// editor an attachment should be inserted into, so the two sides share them
-// instead of each spelling the strings out.
-export const DESCRIPTION_TAB = 'description';
-
-// Holds the body fields that are not markdown, so it has no editor.
-export const OTHER_TAB = 'other';
-
-const FIELD_TAB_PREFIX = 'field-';
-
-export const fieldTab = (fieldId: number) => `${FIELD_TAB_PREFIX}${fieldId}`;
-
-export function fieldTabId(tab: string): number | null {
- if (!tab.startsWith(FIELD_TAB_PREFIX)) return null;
- const id = Number(tab.slice(FIELD_TAB_PREFIX.length));
- return Number.isNaN(id) ? null : id;
-}
diff --git a/apps/web/src/features/issue/utils/fieldValues.ts b/apps/web/src/features/issue/utils/fieldValues.ts
new file mode 100644
index 00000000..5c701998
--- /dev/null
+++ b/apps/web/src/features/issue/utils/fieldValues.ts
@@ -0,0 +1,11 @@
+import { type IssueFieldValueInput } from '@/lib/api';
+
+// Whether a field value carries anything: an empty string and an empty option
+// list read as untouched. The create modal skips such a value on save, and the
+// body switcher marks the sections that have one.
+export function hasFieldValue(
+ value: IssueFieldValueInput | undefined,
+): value is IssueFieldValueInput {
+ if (!value) return false;
+ return (value.optionIds?.length ?? 0) > 0 || (value.value != null && value.value !== '');
+}