Skip to content

Commit 0359000

Browse files
authored
fix: Fix the message editor "disabled" attribute not actually disabling the input (#495)
...
1 parent 28adcd5 commit 0359000

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

apps/array/src/renderer/features/message-editor/components/MessageEditor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export const MessageEditor = forwardRef<EditorHandle, MessageEditorProps>(
7373
sessionId,
7474
taskId,
7575
placeholder,
76-
disabled,
76+
disabled: isDisabled,
77+
isLoading,
7778
isCloud,
7879
autoFocus,
7980
context: { taskId, repoPath },
@@ -138,7 +139,7 @@ export const MessageEditor = forwardRef<EditorHandle, MessageEditorProps>(
138139
<Flex justify="between" align="center">
139140
<Flex gap="2" align="center">
140141
<EditorToolbar
141-
disabled={disabled}
142+
disabled={isDisabled}
142143
taskId={taskId}
143144
onInsertChip={insertChip}
144145
onAttachFiles={onAttachFiles}

apps/array/src/renderer/features/message-editor/tiptap/useTiptapEditor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface UseTiptapEditorOptions {
1212
taskId?: string;
1313
placeholder?: string;
1414
disabled?: boolean;
15+
isLoading?: boolean;
1516
isCloud?: boolean;
1617
autoFocus?: boolean;
1718
context?: DraftContext;
@@ -35,6 +36,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
3536
taskId,
3637
placeholder = "",
3738
disabled = false,
39+
isLoading = false,
3840
isCloud = false,
3941
autoFocus = false,
4042
context,
@@ -97,6 +99,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
9799
attributes: { class: EDITOR_CLASS },
98100
handleKeyDown: (view, event) => {
99101
if (event.key === "Enter" && !event.shiftKey) {
102+
if (!view.editable) return false;
100103
const suggestionPopup = document.querySelector("[data-tippy-root]");
101104
if (suggestionPopup) return false;
102105
event.preventDefault();
@@ -217,6 +220,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
217220

218221
const submit = useCallback(() => {
219222
if (!editor) return;
223+
if (disabled || isLoading) return;
220224

221225
const text = editor.getText().trim();
222226
if (!text) return;
@@ -236,7 +240,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
236240
editor.commands.clearContent();
237241
prevBashModeRef.current = false;
238242
draft.clearDraft();
239-
}, [editor, isCloud, draft]);
243+
}, [editor, disabled, isLoading, isCloud, draft]);
240244

241245
submitRef.current = submit;
242246

apps/array/src/renderer/features/task-detail/components/TaskInputEditor.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const TaskInputEditor = forwardRef<
5454
const isWorktreeMode = localWorkspaceMode === "worktree";
5555
const isCloudMode = runMode === "cloud";
5656
const { isOnline } = useConnectivity();
57+
const isDisabled = isCreatingTask || !isOnline;
5758

5859
useHotkeys(
5960
"shift+tab",
@@ -82,7 +83,8 @@ export const TaskInputEditor = forwardRef<
8283
} = useTiptapEditor({
8384
sessionId,
8485
placeholder: "What do you want to work on? - @ to add context",
85-
disabled: isCreatingTask,
86+
disabled: isDisabled,
87+
isLoading: isCreatingTask,
8688
isCloud: isCloudMode,
8789
autoFocus: true,
8890
context: { repoPath },
@@ -198,7 +200,7 @@ export const TaskInputEditor = forwardRef<
198200

199201
<Flex justify="between" align="center" px="3" pb="3">
200202
<EditorToolbar
201-
disabled={isCreatingTask}
203+
disabled={isDisabled}
202204
onInsertChip={insertChip}
203205
attachTooltip="Attach files from anywhere"
204206
iconSize={16}
@@ -241,17 +243,13 @@ export const TaskInputEditor = forwardRef<
241243
e.stopPropagation();
242244
onSubmit();
243245
}}
244-
disabled={!canSubmit || isCreatingTask}
246+
disabled={!canSubmit || isDisabled}
245247
loading={isCreatingTask}
246248
style={{
247249
backgroundColor:
248-
!canSubmit || isCreatingTask
249-
? "var(--accent-a4)"
250-
: undefined,
250+
!canSubmit || isDisabled ? "var(--accent-a4)" : undefined,
251251
color:
252-
!canSubmit || isCreatingTask
253-
? "var(--accent-8)"
254-
: undefined,
252+
!canSubmit || isDisabled ? "var(--accent-8)" : undefined,
255253
}}
256254
>
257255
<ArrowUp size={16} weight="bold" />

0 commit comments

Comments
 (0)