[MM-62776] Fix search not working anymore in responsive mode. (#30041)
Этот коммит содержится в:
@@ -155,6 +155,12 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {
|
||||
};
|
||||
}, [hideSearchBar, currentChannelName]);
|
||||
|
||||
useEffect((): void => {
|
||||
if (isMobileView && props.isSideBarRight) {
|
||||
handleFocus();
|
||||
}
|
||||
}, [isMobileView, props.isSideBarRight]);
|
||||
|
||||
useEffect((): void => {
|
||||
if (!isMobileView) {
|
||||
setVisibleSearchHintOptions(determineVisibleSearchHintOptions(searchTerms, searchType));
|
||||
@@ -280,24 +286,27 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {
|
||||
};
|
||||
|
||||
const handleEnterKey = (e: ChangeEvent<HTMLInputElement>): void => {
|
||||
// only prevent default-behaviour, when one of the conditions is true
|
||||
// when both are false just submit the form (default behaviour) with
|
||||
// `handleSubmit` function called from the `form`
|
||||
if (indexChangedViaKeyPress && !searchType && !searchTerms) {
|
||||
e.preventDefault();
|
||||
e.preventDefault();
|
||||
|
||||
if (indexChangedViaKeyPress) {
|
||||
setKeepInputFocused(true);
|
||||
actions.updateSearchType(highlightedSearchHintIndex === 0 ? 'messages' : 'files');
|
||||
setHighlightedSearchHintIndex(-1);
|
||||
} else if (indexChangedViaKeyPress) {
|
||||
e.preventDefault();
|
||||
setKeepInputFocused(true);
|
||||
handleAddSearchTerm(visibleSearchHintOptions[highlightedSearchHintIndex].searchTerm);
|
||||
if (!searchType && !searchTerms) {
|
||||
actions.updateSearchType(highlightedSearchHintIndex === 0 ? 'messages' : 'files');
|
||||
setHighlightedSearchHintIndex(-1);
|
||||
} else {
|
||||
handleAddSearchTerm(visibleSearchHintOptions[highlightedSearchHintIndex].searchTerm);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (props.isMentionSearch) {
|
||||
e.preventDefault();
|
||||
actions.updateRhsState(RHSStates.SEARCH);
|
||||
}
|
||||
|
||||
handleSearch().then(() => {
|
||||
setKeepInputFocused(false);
|
||||
setFocused(false);
|
||||
});
|
||||
};
|
||||
|
||||
const handleSubmit = (e: FormEvent<HTMLFormElement>): void => {
|
||||
|
||||
Ссылка в новой задаче
Block a user