mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 21:33:19 +00:00
fix(collab): keep the keyboard open after sending a chat message
The send button in the trip chat cancels its mousedown like the note format bar, so the native app no longer closes the keyboard after every message.
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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')}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user