From 8a15dfc26bb20bc81a47b575e51e509cbfced182 Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Thu, 26 Dec 2024 22:17:40 -1000 Subject: [PATCH] feat(zbugs): Put limits on textareas too for UI feedback. --- apps/zbugs/src/limits.ts | 8 ++++++++ apps/zbugs/src/pages/issue/comment-composer.tsx | 3 +++ apps/zbugs/src/pages/issue/issue-composer.tsx | 6 ++++++ apps/zbugs/src/pages/issue/issue-page.tsx | 6 ++++++ 4 files changed, 23 insertions(+) create mode 100644 apps/zbugs/src/limits.ts diff --git a/apps/zbugs/src/limits.ts b/apps/zbugs/src/limits.ts new file mode 100644 index 000000000..c3631fab3 --- /dev/null +++ b/apps/zbugs/src/limits.ts @@ -0,0 +1,8 @@ +// NOTE: These limits are also in the postgres schema. These here are just for +// UI feedback. +export const MAX_ISSUE_TITLE_LENGTH = 128; +export const MAX_ISSUE_DESCRIPTION_LENGTH = 10 * 1024; + +// The launch post has a special maxLength because trolls. +export const maxCommentLength = (issueID: string) => + issueID === 'duuW9Nyj5cTNLlimp9Qje' ? 1024 : 64 * 1024; diff --git a/apps/zbugs/src/pages/issue/comment-composer.tsx b/apps/zbugs/src/pages/issue/comment-composer.tsx index 939fb42eb..1de1d4c69 100644 --- a/apps/zbugs/src/pages/issue/comment-composer.tsx +++ b/apps/zbugs/src/pages/issue/comment-composer.tsx @@ -4,6 +4,7 @@ import {Button} from '../../components/button.js'; import {useLogin} from '../../hooks/use-login.js'; import {useZero} from '../../hooks/use-zero.js'; import {isCtrlEnter} from './is-ctrl-enter.js'; +import {maxCommentLength} from '../../limits.js'; export function CommentComposer({ id, @@ -83,6 +84,8 @@ export function CommentComposer({ onChange={handleChange} onKeyDown={handleKeyDown} className="comment-input autoResize" + /* The launch post has a speical maxLength because trolls */ + maxLength={maxCommentLength(issueID)} />