-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: autocomplete items clicking works on webkit (#1494)
fix: autocomplete items clicking works on webkit
- Loading branch information
Showing
7 changed files
with
113 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v14.0.0 | ||
lts/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* eslint-disable jest/no-done-callback */ | ||
/* eslint-disable jest/require-top-level-describe */ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test.describe('autocomplete a mention', () => { | ||
test('should fill in textarea with username', async ({ baseURL, page }) => { | ||
await page.goto(`${baseURL}/?story=hello--basic-setup`); | ||
await page.waitForSelector('[data-storyloaded]'); | ||
await page.fill('data-testid=message-input', '@'); | ||
const button = await page.locator( | ||
'button.rta__entity >> :nth-match(span.str-chat__user-item--name, 1)', | ||
); | ||
button.click(); | ||
const textContent = await button.textContent(); | ||
|
||
await expect(page.locator('data-testid=message-input')).toContainText(`@${textContent}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import '@stream-io/stream-chat-css/dist/css/index.css'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { ChannelFilters, ChannelOptions, ChannelSort, Event, StreamChat } from 'stream-chat'; | ||
import { | ||
Channel, | ||
ChannelHeader, | ||
ChannelList, | ||
Chat, | ||
MessageInput, | ||
MessageList, | ||
Thread, | ||
Window, | ||
} from '../index'; | ||
import { apiKey, StreamChatGenerics } from './utils'; | ||
|
||
const channelId = import.meta.env.E2E_ADD_MESSAGE_CHANNEL; | ||
const userId = import.meta.env.E2E_TEST_USER_1 as string; | ||
const token = import.meta.env.E2E_TEST_USER_1_TOKEN as string; | ||
|
||
if (!channelId || typeof channelId !== 'string') { | ||
throw new Error('expected ADD_MESSAGE_CHANNEL'); | ||
} | ||
|
||
// Sort in reverse order to avoid auto-selecting unread channel | ||
const sort: ChannelSort = { last_updated: 1 }; | ||
const filters: ChannelFilters = { members: { $in: [userId] }, type: 'messaging' }; | ||
const options: ChannelOptions = { limit: 10, presence: true, state: true }; | ||
|
||
const chatClient = StreamChat.getInstance<StreamChatGenerics>(apiKey); | ||
let sharedPromise = Promise.resolve(); | ||
|
||
export const BasicSetup = () => { | ||
const [connected, setConnected] = useState(false); | ||
|
||
useEffect(() => { | ||
sharedPromise.then(() => chatClient.connectUser({ id: userId }, token)); | ||
|
||
const handleConnectionChange = ({ online = false }: Event) => { | ||
setConnected(online); | ||
}; | ||
|
||
chatClient.on('connection.changed', handleConnectionChange); | ||
|
||
return () => { | ||
chatClient.off('connection.changed', handleConnectionChange); | ||
sharedPromise = chatClient.disconnectUser(); | ||
}; | ||
}, []); | ||
|
||
if (!connected) { | ||
return <p>Connecting {userId}...</p>; | ||
} | ||
|
||
return ( | ||
<Chat client={chatClient}> | ||
<ChannelList filters={filters} options={options} showChannelSearch sort={sort} /> | ||
<Channel> | ||
<Window> | ||
<ChannelHeader /> | ||
<MessageList /> | ||
<MessageInput focus /> | ||
</Window> | ||
<Thread /> | ||
</Channel> | ||
</Chat> | ||
); | ||
}; |