Skip to content

Commit 94a2bb1

Browse files
committed
improvement(rich-md-editor): make read-only PromptEditor fully display-only
Greptile P2: a padding click on the read-only editor still focused the non-editable textarea, which can read as editable. Gate the surface-click focus on `!readOnly`, and drop the blinking caret (`caret-transparent` + `cursor-default`) in read-only mode. Text stays selectable for copy.
1 parent 67f9de3 commit 94a2bb1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor

apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/prompt-editor.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,17 @@ export function PromptEditor({
8989
/**
9090
* Clicking the editor's empty regions (padding, space below the last line)
9191
* focuses the textarea; clicks on the textarea itself keep native caret
92-
* placement.
92+
* placement. No-op in read-only mode: the surface is display-only, so a
93+
* padding click should not pull focus onto the non-editable textarea.
9394
*/
9495
const handleSurfaceClick = useCallback(
9596
(e: React.MouseEvent<HTMLDivElement>) => {
97+
if (readOnly) return
9698
if (e.target === textareaRef.current) return
9799
if ((e.target as HTMLElement).closest('button')) return
98100
textareaRef.current?.focus()
99101
},
100-
[textareaRef]
102+
[readOnly, textareaRef]
101103
)
102104

103105
const overlayContent = useMemo(() => {
@@ -189,7 +191,7 @@ export function PromptEditor({
189191
placeholder={placeholder}
190192
aria-label={ariaLabel}
191193
rows={1}
192-
className={TEXTAREA_BASE_CLASSES}
194+
className={cn(TEXTAREA_BASE_CLASSES, readOnly && 'cursor-default caret-transparent')}
193195
/>
194196
</div>
195197

0 commit comments

Comments
 (0)