Skip to content

Commit 9d33c10

Browse files
authored
ux: Makes text area buttons appear only when there's text (RooCodeInc#7987)
1 parent d54ff8a commit 9d33c10

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
246246

247247
const allModes = useMemo(() => getAllModes(customModes), [customModes])
248248

249+
// Memoized check for whether the input has content
250+
const hasInputContent = useMemo(() => {
251+
return inputValue.trim().length > 0
252+
}, [inputValue])
253+
249254
const queryItems = useMemo(() => {
250255
return [
251256
{ type: ContextMenuOptionType.Problems, value: "problems" },
@@ -1088,12 +1093,16 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
10881093
"relative inline-flex items-center justify-center",
10891094
"bg-transparent border-none p-1.5",
10901095
"rounded-md min-w-[28px] min-h-[28px]",
1091-
"opacity-60 hover:opacity-100 text-vscode-descriptionForeground hover:text-vscode-foreground",
1092-
"transition-all duration-150",
1093-
"hover:bg-[rgba(255,255,255,0.03)] hover:border-[rgba(255,255,255,0.15)]",
1094-
"focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder",
1095-
"active:bg-[rgba(255,255,255,0.1)]",
1096+
"text-vscode-descriptionForeground hover:text-vscode-foreground",
1097+
"transition-all duration-1000",
10961098
"cursor-pointer",
1099+
hasInputContent
1100+
? "opacity-50 hover:opacity-100 delay-750 pointer-events-auto"
1101+
: "opacity-0 pointer-events-none duration-200 delay-0",
1102+
hasInputContent &&
1103+
"hover:bg-[rgba(255,255,255,0.03)] hover:border-[rgba(255,255,255,0.15)]",
1104+
"focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder",
1105+
hasInputContent && "active:bg-[rgba(255,255,255,0.1)]",
10971106
)}>
10981107
<WandSparkles className={cn("w-4 h-4", isEnhancingPrompt && "animate-spin")} />
10991108
</button>
@@ -1131,12 +1140,16 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
11311140
"relative inline-flex items-center justify-center",
11321141
"bg-transparent border-none p-1.5",
11331142
"rounded-md min-w-[28px] min-h-[28px]",
1134-
"opacity-60 hover:opacity-100 text-vscode-descriptionForeground hover:text-vscode-foreground",
1135-
"transition-all duration-150",
1136-
"hover:bg-[rgba(255,255,255,0.03)] hover:border-[rgba(255,255,255,0.15)]",
1143+
"text-vscode-descriptionForeground hover:text-vscode-foreground",
1144+
"transition-all duration-200",
1145+
hasInputContent
1146+
? "opacity-100 hover:opacity-100 pointer-events-auto"
1147+
: "opacity-0 pointer-events-none",
1148+
hasInputContent &&
1149+
"hover:bg-[rgba(255,255,255,0.03)] hover:border-[rgba(255,255,255,0.15)]",
11371150
"focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder",
1138-
"active:bg-[rgba(255,255,255,0.1)]",
1139-
"cursor-pointer",
1151+
hasInputContent && "active:bg-[rgba(255,255,255,0.1)]",
1152+
hasInputContent && "cursor-pointer",
11401153
)}>
11411154
<SendHorizontal className="w-4 h-4" />
11421155
</button>

0 commit comments

Comments
 (0)