fix: resolve issues with search functionality
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useContext, useEffect, useMemo } from 'react';
|
||||
import React, { useContext, useEffect } from 'react';
|
||||
|
||||
import camelCase from 'lodash/camelCase';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
@@ -22,18 +22,14 @@ function Search({ intl }) {
|
||||
const isPostSearch = ['posts', 'my-posts'].includes(page);
|
||||
const isTopicSearch = 'topics'.includes(page);
|
||||
let searchValue = '';
|
||||
|
||||
const currentValue = useMemo(() => {
|
||||
let value = '';
|
||||
if (isPostSearch) {
|
||||
value = postSearch;
|
||||
} else if (isTopicSearch) {
|
||||
value = topicSearch;
|
||||
} else {
|
||||
value = learnerSearch;
|
||||
}
|
||||
return value;
|
||||
}, [isPostSearch, isTopicSearch, learnerSearch]);
|
||||
let currentValue = '';
|
||||
if (isPostSearch) {
|
||||
currentValue = postSearch;
|
||||
} else if (isTopicSearch) {
|
||||
currentValue = topicSearch;
|
||||
} else {
|
||||
currentValue = learnerSearch;
|
||||
}
|
||||
|
||||
const onClear = () => {
|
||||
dispatch(setSearchQuery(''));
|
||||
|
||||
@@ -18,7 +18,7 @@ function SearchInfo({
|
||||
return (
|
||||
<div className="d-flex flex-row border-bottom">
|
||||
<Icon src={Search} className="justify-content-start ml-3.5 mr-2 mb-2 mt-2.5" />
|
||||
<Button variant="" size="inline">
|
||||
<Button variant="" size="inline" className="text-primary-500">
|
||||
{
|
||||
loadingStatus === RequestStatus.SUCCESSFUL
|
||||
? intl.formatMessage(messages.searchInfo, { count, text })
|
||||
|
||||
@@ -44,6 +44,7 @@ const learnersSlice = createSlice({
|
||||
},
|
||||
setUsernameSearch: (state, { payload }) => {
|
||||
state.usernameSearch = payload;
|
||||
state.pages = [];
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -128,6 +128,11 @@ const messages = defineMessages({
|
||||
defaultMessage: 'Try searching different keywords or removing some filters',
|
||||
description: 'Message shown on discussion sidebar if user searched with keywords.',
|
||||
},
|
||||
removeKeywordsOnly: {
|
||||
id: 'discussions.sidebar.removeKeywordsOnly',
|
||||
defaultMessage: 'Try searching different keywords',
|
||||
description: 'Message shown on discussion sidebar if user searched with keywords only.',
|
||||
},
|
||||
removeFilters: {
|
||||
id: 'discussions.sidebar.removeFilters',
|
||||
defaultMessage: 'Try removing some filters',
|
||||
|
||||
@@ -15,8 +15,10 @@ function NoResults({ intl }) {
|
||||
let helpMessage = messages.removeFilters;
|
||||
if (!isFiltered) {
|
||||
return null;
|
||||
} if (filters.search || topicsFilter || learnersFilter) {
|
||||
} if (filters.search || learnersFilter) {
|
||||
helpMessage = messages.removeKeywords;
|
||||
} if (topicsFilter) {
|
||||
helpMessage = messages.removeKeywordsOnly;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -32,7 +32,7 @@ const messages = defineMessages({
|
||||
},
|
||||
clearSearch: {
|
||||
id: 'discussions.actionBar.clearSearch',
|
||||
defaultMessage: 'Clear',
|
||||
defaultMessage: 'Clear results',
|
||||
description: 'Button to clear search',
|
||||
},
|
||||
addAPost: {
|
||||
|
||||
Reference in New Issue
Block a user