Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(collab): keep the keyboard open after sending a chat message

Maurice091ad0f23dc0
diff --git a/client/src/components/Collab/CollabChat.test.tsx b/client/src/components/Collab/CollabChat.test.tsx
index 2b1230be5..ff341e9b3 100644
--- a/client/src/components/Collab/CollabChat.test.tsx
+++ b/client/src/components/Collab/CollabChat.test.tsx
@@ -288,6 +288,14 @@ describe('CollabChat', () => {
expect(screen.getByText(/deleted/i)).toBeInTheDocument();
});
+ it('FE-COMP-CHAT-038: the send button keeps the focus in the message field', async () => {
+ render(<CollabChat {...defaultProps} />);
+ await screen.findByText('Start the conversation');
+ fireEvent.change(screen.getByPlaceholderText('Type a message...'), { target: { value: 'One more' } });
+ const sendButton = screen.getAllByRole('button').find(b => b.querySelector('.lucide-arrow-up'));
+ expect(sendButton && fireEvent.mouseDown(sendButton)).toBe(false);
+ });
+
it('FE-COMP-CHAT-020: send button is disabled when input is empty', async () => {
render(<CollabChat {...defaultProps} />);
await screen.findByText('Start the conversation');
diff --git a/client/src/components/Collab/CollabChat.tsx b/client/src/components/Collab/CollabChat.tsx
index 3aa3342c6..2f8c090a1 100644
--- a/client/src/components/Collab/CollabChat.tsx
+++ b/client/src/components/Collab/CollabChat.tsx
@@ -85,7 +85,7 @@ export default function CollabChat({ tripId, currentUser }: CollabChatProps) {
{/* Send */}
{canEdit && (
- <button type="button" onClick={handleSend} disabled={(!text.trim() && !imageFiles.length) || sending} style={{
+ <button type="button" onMouseDown={e => e.preventDefault()} onClick={handleSend} disabled={(!text.trim() && !imageFiles.length) || sending} style={{
width: 34, height: 34, borderRadius: '50%', border: 'none',
background: text.trim() || imageFiles.length ? 'var(--accent)' : 'var(--border-primary)',
color: text.trim() || imageFiles.length ? 'var(--accent-text)' : 'var(--text-faint)', display: 'flex', alignItems: 'center', justifyContent: 'center',
diff --git a/client/src/mobile/screens/trip/tabs/MCollabChat.tsx b/client/src/mobile/screens/trip/tabs/MCollabChat.tsx
index 850dacda1..ab6dbf086 100644
--- a/client/src/mobile/screens/trip/tabs/MCollabChat.tsx
+++ b/client/src/mobile/screens/trip/tabs/MCollabChat.tsx
@@ -217,6 +217,7 @@ export default function MCollabChat({ planner }: MCollabChatProps) {
/>
<button
type="button"
+ onMouseDown={e => e.preventDefault()}
onClick={handleSend}
disabled={(!text.trim() && !images.files.length) || sending}
aria-label={t('collab.chat.send')}
diff --git a/client/tests/unit/mobile/trip/MCollabChat.test.tsx b/client/tests/unit/mobile/trip/MCollabChat.test.tsx
index a5c702969..ba277f117 100644
--- a/client/tests/unit/mobile/trip/MCollabChat.test.tsx
+++ b/client/tests/unit/mobile/trip/MCollabChat.test.tsx
@@ -271,6 +271,13 @@ describe('MCollabChat', () => {
expect(input).toHaveValue('')
})
+ it('FE-MOB-CCHAT-038: the send button keeps the focus in the composer, so the keyboard stays open', async () => {
+ serveMessages([])
+ await renderChat()
+ fireEvent.change(screen.getByPlaceholderText('collab.chat.placeholder'), { target: { value: 'One more' } })
+ expect(fireEvent.mouseDown(screen.getByRole('button', { name: 'collab.chat.send' }))).toBe(false)
+ })
+
it('FE-MOB-CCHAT-014: keeps the draft and toasts when sending fails', async () => {
serveMessages([])
serveSend(() => chatMsg(1), true)