Skip to content

Commit 21fb0c2

Browse files
committed
fix: show send button when only images are selected in chat textarea
- Updated hasInputContent logic to check for both text content and selected images - Added comprehensive tests for send button visibility scenarios - Fixes issue where send button was hidden when user had only attached images
1 parent c552027 commit 21fb0c2

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

tmp/Roo-Code

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8111da66bd59ca8d500e5eae23b24a0419ed7345

tmp/Roo-Code-rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 7b7bb49572975c4aeff2381a0ebea99b3aa4542c

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
247247

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

250-
// Memoized check for whether the input has content
250+
// Memoized check for whether the input has content (text or images)
251251
const hasInputContent = useMemo(() => {
252-
return inputValue.trim().length > 0
253-
}, [inputValue])
252+
return inputValue.trim().length > 0 || selectedImages.length > 0
253+
}, [inputValue, selectedImages])
254254

255255
const queryItems = useMemo(() => {
256256
return [

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,4 +1057,70 @@ describe("ChatTextArea", () => {
10571057
expect(apiConfigDropdown).toHaveAttribute("disabled")
10581058
})
10591059
})
1060+
1061+
describe("send button visibility", () => {
1062+
it("should show send button when there are images but no text", () => {
1063+
const { container } = render(
1064+
<ChatTextArea
1065+
{...defaultProps}
1066+
inputValue=""
1067+
selectedImages={["data:image/png;base64,test1", "data:image/png;base64,test2"]}
1068+
/>,
1069+
)
1070+
1071+
// Find the send button by its icon
1072+
const sendButton = container.querySelector('button[aria-label="Send message"]')
1073+
expect(sendButton).toBeInTheDocument()
1074+
1075+
// Check that the button is visible (has opacity-100 class when content exists)
1076+
expect(sendButton).toHaveClass("opacity-100")
1077+
expect(sendButton).toHaveClass("pointer-events-auto")
1078+
expect(sendButton).not.toHaveClass("opacity-0")
1079+
expect(sendButton).not.toHaveClass("pointer-events-none")
1080+
})
1081+
1082+
it("should hide send button when there is no text and no images", () => {
1083+
const { container } = render(<ChatTextArea {...defaultProps} inputValue="" selectedImages={[]} />)
1084+
1085+
// Find the send button by its icon
1086+
const sendButton = container.querySelector('button[aria-label="Send message"]')
1087+
expect(sendButton).toBeInTheDocument()
1088+
1089+
// Check that the button is hidden (has opacity-0 class when no content)
1090+
expect(sendButton).toHaveClass("opacity-0")
1091+
expect(sendButton).toHaveClass("pointer-events-none")
1092+
expect(sendButton).not.toHaveClass("opacity-100")
1093+
expect(sendButton).not.toHaveClass("pointer-events-auto")
1094+
})
1095+
1096+
it("should show send button when there is text but no images", () => {
1097+
const { container } = render(<ChatTextArea {...defaultProps} inputValue="Some text" selectedImages={[]} />)
1098+
1099+
// Find the send button by its icon
1100+
const sendButton = container.querySelector('button[aria-label="Send message"]')
1101+
expect(sendButton).toBeInTheDocument()
1102+
1103+
// Check that the button is visible
1104+
expect(sendButton).toHaveClass("opacity-100")
1105+
expect(sendButton).toHaveClass("pointer-events-auto")
1106+
})
1107+
1108+
it("should show send button when there is both text and images", () => {
1109+
const { container } = render(
1110+
<ChatTextArea
1111+
{...defaultProps}
1112+
inputValue="Some text"
1113+
selectedImages={["data:image/png;base64,test1"]}
1114+
/>,
1115+
)
1116+
1117+
// Find the send button by its icon
1118+
const sendButton = container.querySelector('button[aria-label="Send message"]')
1119+
expect(sendButton).toBeInTheDocument()
1120+
1121+
// Check that the button is visible
1122+
expect(sendButton).toHaveClass("opacity-100")
1123+
expect(sendButton).toHaveClass("pointer-events-auto")
1124+
})
1125+
})
10601126
})

0 commit comments

Comments
 (0)