mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 22:27:32 +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',
|
||||
|
||||
Reference in New Issue
Block a user