diff --git a/app/assets/stylesheets/chat.scss b/app/assets/stylesheets/chat.scss
index b83357a43..7f7cee5c1 100644
--- a/app/assets/stylesheets/chat.scss
+++ b/app/assets/stylesheets/chat.scss
@@ -1066,7 +1066,7 @@
display: none;
z-index: 1;
border-top: 1px solid #dbdbdb;
- bottom: 60px;
+ bottom: 90px;
width: 100%;
max-height: 280px;
overflow-x: scroll;
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 65550cad9..d912ab8cf 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -59,7 +59,7 @@ class SearchController < ApplicationController
def chat_channels
search_user_id = if chat_channel_params[:user_id].present?
- [current_user.id, SiteConfig.mascot_user_id]
+ [current_user.id, SiteConfig.mascot_user_id, chat_channel_params[:user_id]].reject(&:blank?)
else
[current_user.id]
end
diff --git a/app/javascript/chat/__tests__/chat.test.jsx b/app/javascript/chat/__tests__/chat.test.jsx
index 66f1040d4..46a296c39 100644
--- a/app/javascript/chat/__tests__/chat.test.jsx
+++ b/app/javascript/chat/__tests__/chat.test.jsx
@@ -1,5 +1,5 @@
import { h } from 'preact';
-import { render } from '@testing-library/preact';
+import { fireEvent, render } from '@testing-library/preact';
import fetch from 'jest-fetch-mock';
import { JSDOM } from 'jsdom';
import { axe } from 'jest-axe';
@@ -226,4 +226,19 @@ describe('', () => {
}),
).toBeDefined();
});
+
+ it('should show mention pop-up on keyUp @', async () => {
+ const { getByLabelText, getByTestId } = render();
+
+ const inputField = getByLabelText('Compose a message');
+
+ expect(inputField).toBeDefined();
+ fireEvent.change(inputField, { target: { value: '@' } });
+
+ const mentionModal = getByTestId('mentionList');
+ const allButton = getByTestId('all');
+
+ expect(mentionModal).toBeDefined();
+ expect(allButton).toBeDefined();
+ });
});
diff --git a/app/javascript/chat/chat.jsx b/app/javascript/chat/chat.jsx
index c5d367ac0..e82c4b91d 100644
--- a/app/javascript/chat/chat.jsx
+++ b/app/javascript/chat/chat.jsx
@@ -261,7 +261,7 @@ export default class Chat extends Component {
activeChannel ||
this.filterForActiveChannel(channels, activeChannelId),
});
- this.setupChannel(activeChannelId);
+ this.setupChannel(activeChannelId, activeChannel);
} else if (activeChannelId) {
this.setState({
scrolled: false,
@@ -273,7 +273,7 @@ export default class Chat extends Component {
activeChannel ||
this.filterForActiveChannel(channels, activeChannelId),
});
- this.setupChannel(activeChannelId);
+ this.setupChannel(activeChannelId, activeChannel);
} else if (channels.length > 0) {
this.setState({
chatChannels: channels,
@@ -288,6 +288,7 @@ export default class Chat extends Component {
channels[0].channel_modified_slug,
channels,
);
+ this.setupChannels(channels);
} else {
this.setState({ channelsLoaded: true });
}
@@ -323,9 +324,10 @@ export default class Chat extends Component {
};
setupChannels = (channels) => {
+ const { activeChannel } = this.state;
channels.forEach((channel, index) => {
if (index < 3) {
- this.setupChannel(channel.chat_channel_id);
+ this.setupChannel(channel.chat_channel_id, activeChannel);
}
});
};
@@ -353,8 +355,8 @@ export default class Chat extends Component {
});
};
- setupChannel = (channelId) => {
- const { messages, messageOffset, activeChannel, appDomain } = this.state;
+ setupChannel = (channelId, activeChannel) => {
+ const { messages, messageOffset, appDomain } = this.state;
if (
!messages[channelId] ||
messages[channelId].length === 0 ||
@@ -362,7 +364,11 @@ export default class Chat extends Component {
) {
getAllMessages(channelId, messageOffset, this.receiveAllMessages);
}
- if (activeChannel && activeChannel.channel_type !== 'direct') {
+ if (
+ activeChannel &&
+ activeChannel.channel_type !== 'direct' &&
+ activeChannel.chat_channel_id === channelId
+ ) {
getContent(
`/chat_channels/${channelId}/channel_info`,
this.setOpenChannelUsers,
@@ -822,21 +828,26 @@ export default class Chat extends Component {
if (index > -1) {
newUnopenedChannelIds.splice(index, 1);
}
+
+ let updatedActiveChannel = this.filterForActiveChannel(
+ channelList,
+ id,
+ currentUserId,
+ );
+
this.setState({
- activeChannel: this.filterForActiveChannel(
- channelList,
- id,
- currentUserId,
- ),
+ activeChannel: updatedActiveChannel,
activeChannelId: parseInt(id, 10),
scrolled: false,
showAlert: false,
allMessagesLoaded: false,
+ showMemberlist: false,
unopenedChannelIds: unopenedChannelIds.filter(
(unopenedId) => unopenedId !== id,
),
});
- this.setupChannel(id);
+
+ this.setupChannel(id, updatedActiveChannel);
const params = new URLSearchParams(window.location.search);
if (params.get('ref') === 'group_invite') {
@@ -1231,6 +1242,7 @@ export default class Chat extends Component {