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