Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-31708][MM-31726][MM-31739][MM-31727] - Fix regressions in RHS and Status menu #7290

Merged
merged 3 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions components/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {
const intl = useIntl();

// generate intial component state and setters
const [focussed, setFocussed] = useState<boolean>(false);
const [keepInputFocussed, setKeepInputFocussed] = useState<boolean>(false);
const [focused, setFocused] = useState<boolean>(false);
const [keepInputFocused, setKeepInputFocused] = useState<boolean>(false);
const [indexChangedViaKeyPress, setIndexChangedViaKeyPress] = useState<boolean>(false);
const [highlightedSearchHintIndex, setHighlightedSearchHintIndex] = useState<number>(-1);
const [visibleSearchHintOptions, setVisibleSearchHintOptions] = useState<SearchHintOption[]>(
Expand All @@ -85,13 +85,13 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {
}, [searchTerms]);

useEffect((): void => {
if (!Utils.isMobile() && focussed && keepInputFocussed) {
if (!Utils.isMobile() && focused && keepInputFocused) {
handleBlur();
}
}, [searchTerms]);

useEffect((): void => {
if (props.isFocus) {
if (props.isFocus && !props.isRhsOpen) {
handleFocus();
} else {
handleBlur();
Expand All @@ -102,30 +102,30 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {
const handleClose = (): void => actions.closeRightHandSide();

// focus the search input
const handleFocus = (): void => setFocussed(true);
const handleFocus = (): void => setFocused(true);

// release focus from the search input or unset `keepInputFocussed` value
// `keepInputFocussed` is used to keep the search input focussed when a
// release focus from the search input or unset `keepInputFocused` value
// `keepInputFocused` is used to keep the search input focused when a
// user selects a suggestion from `SearchHint` with a click
const handleBlur = (): void => {
// add time out so that the pinned and member buttons are clickable
// when focus is released from the search box.
setTimeout((): void => {
if (keepInputFocussed) {
setKeepInputFocussed(false);
if (keepInputFocused) {
setKeepInputFocused(false);
} else {
setFocussed(false);
setFocused(false);
}
}, 0);

updateHighlightedSearchHint();
};

const handleSearchHintSelection = (): void => {
if (focussed) {
setKeepInputFocussed(true);
if (focused) {
setKeepInputFocused(true);
} else {
setFocussed(true);
setFocused(true);
}
};

Expand Down Expand Up @@ -177,7 +177,7 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {
// `handleSubmit` function called from the `form`
if (indexChangedViaKeyPress) {
e.preventDefault();
setKeepInputFocussed(true);
setKeepInputFocused(true);
handleAddSearchTerm(visibleSearchHintOptions[highlightedSearchHintIndex].searchTerm);
}

Expand All @@ -191,8 +191,8 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {
e.preventDefault();

handleSearch().then(() => {
setKeepInputFocussed(false);
setFocussed(false);
setKeepInputFocused(false);
setFocused(false);
});
};

Expand All @@ -218,7 +218,7 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {

const handleClear = (): void => {
if (props.isMentionSearch) {
setFocussed(false);
setFocused(false);
actions.updateRhsState(RHSStates.SEARCH);
}
actions.updateSearchTerms('');
Expand Down Expand Up @@ -301,7 +301,7 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {
return <></>;
}

const helpClass = `search-help-popover${(focussed && termsUsed <= 2) ? ' visible' : ''}`;
const helpClass = `search-help-popover${(focused && termsUsed <= 2) ? ' visible' : ''}`;

return (
<Popover
Expand Down Expand Up @@ -343,8 +343,8 @@ const Search: React.FC<Props> = (props: Props): JSX.Element => {
handleSubmit={handleSubmit}
handleFocus={handleFocus}
handleBlur={handleBlur}
keepFocussed={keepInputFocussed}
isFocussed={focussed}
keepFocused={keepInputFocused}
isFocused={focused}
suggestionProviders={suggestionProviders.current}
isSideBarRight={props.isSideBarRight}
isSearchingTerm={props.isSearchingTerm}
Expand Down
14 changes: 8 additions & 6 deletions components/search_bar/__snapshots__/search_bar.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ exports[`components/search_bar/SearchBar should match snapshot with search 1`] =
handleFocus={[MockFunction]}
handleSubmit={[MockFunction]}
isFocus={false}
isFocussed={false}
isFocused={false}
isSearchingTerm={false}
isSideBarRight={false}
keepFocussed={false}
keepFocused={false}
searchTerms="test"
suggestionProviders={
Array [
Expand Down Expand Up @@ -124,10 +124,10 @@ exports[`components/search_bar/SearchBar should match snapshot without search 1`
handleFocus={[MockFunction]}
handleSubmit={[MockFunction]}
isFocus={false}
isFocussed={false}
isFocused={false}
isSearchingTerm={false}
isSideBarRight={false}
keepFocussed={false}
keepFocused={false}
searchTerms=""
suggestionProviders={
Array [
Expand Down Expand Up @@ -203,10 +203,11 @@ exports[`components/search_bar/SearchBar should match snapshot without search on
handleFocus={[MockFunction]}
handleSubmit={[MockFunction]}
isFocus={false}
isFocused={false}
isFocussed={true}
isSearchingTerm={false}
isSideBarRight={false}
keepFocussed={false}
keepFocused={false}
searchTerms=""
suggestionProviders={
Array [
Expand Down Expand Up @@ -282,10 +283,11 @@ exports[`components/search_bar/SearchBar should match snapshot without search on
handleFocus={[MockFunction]}
handleSubmit={[MockFunction]}
isFocus={false}
isFocused={false}
isFocussed={true}
isSearchingTerm={false}
isSideBarRight={false}
keepFocussed={false}
keepFocused={false}
searchTerms=""
suggestionProviders={
Array [
Expand Down
4 changes: 2 additions & 2 deletions components/search_bar/search_bar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe('components/search_bar/SearchBar', () => {
const baseProps = {
suggestionProviders,
searchTerms: '',
keepFocussed: false,
isFocussed: false,
keepFocused: false,
isFocused: false,
isSideBarRight: false,
isSearchingTerm: false,
isFocus: false,
Expand Down
14 changes: 7 additions & 7 deletions components/search_bar/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type Props = {
handleClear: () => void;
handleFocus: () => void;
handleBlur: () => void;
keepFocussed: boolean;
isFocussed: boolean;
keepFocused: boolean;
isFocused: boolean;
suggestionProviders: Provider[];
isSearchingTerm: boolean;
isFocus: boolean;
Expand All @@ -45,23 +45,23 @@ const defaultProps: Partial<Props> = {
};

const SearchBar: React.FunctionComponent<Props> = (props: Props): JSX.Element => {
const {isFocussed, keepFocussed, searchTerms, suggestionProviders} = props;
const {isFocused, keepFocused, searchTerms, suggestionProviders} = props;

const searchRef = useRef<SuggestionBox>();
const intl = useIntl();

useEffect((): void => {
const shouldFocus = isFocussed || keepFocussed;
const shouldFocus = isFocused || keepFocused;
if (shouldFocus) {
// let redux handle changes before focussing the input
setTimeout(() => searchRef.current?.focus(), 0);
} else {
setTimeout(() => searchRef.current?.blur(), 0);
}
}, [isFocussed, keepFocussed]);
}, [isFocused, keepFocused]);

useEffect((): void => {
if (isFocussed && !keepFocussed && searchTerms.endsWith('""')) {
if (isFocused && !keepFocused && searchTerms.endsWith('""')) {
setTimeout(() => searchRef.current?.focus(), 0);
}
}, [searchTerms]);
Expand Down Expand Up @@ -102,7 +102,7 @@ const SearchBar: React.FunctionComponent<Props> = (props: Props): JSX.Element =>
>
<form
role='application'
className={classNames(['search__form', {'search__form--focused': isFocussed}])}
className={classNames(['search__form', {'search__form--focused': isFocused}])}
onSubmit={props.handleSubmit}
style={style.searchForm}
autoComplete='off'
Expand Down
2 changes: 1 addition & 1 deletion components/search_results/search_results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const SearchResults: React.FC<Props> = (props: Props): JSX.Element => {
</div>
);
break;
case (noResults && !searchTerms && !isMentionSearch):
case (noResults && !searchTerms && !isMentionSearch && !isPinnedPosts && !isFlaggedPosts):
contentItems = (
<div className='sidebar--right__subheader search__hints a11y__section'>
<SearchHint
Expand Down
16 changes: 10 additions & 6 deletions components/sidebar_right/sidebar_right.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {trackEvent} from 'actions/telemetry_actions.jsx';
import Constants from 'utils/constants';
import * as Utils from 'utils/utils.jsx';

import FileUploadOverlay from 'components/file_upload_overlay';
import RhsThread from 'components/rhs_thread';
import RhsCard from 'components/rhs_card';
import Search from 'components/search/index.tsx';
Expand Down Expand Up @@ -168,12 +169,15 @@ export default class SidebarRight extends React.PureComponent {
switch (true) {
case postRightVisible:
content = (
<RhsThread
previousRhsState={previousRhsState}
currentUserId={currentUserId}
toggleSize={this.toggleSize}
shrink={this.onShrink}
/>
<div className='post-right__container'>
<FileUploadOverlay overlayType='right'/>
<RhsThread
previousRhsState={previousRhsState}
currentUserId={currentUserId}
toggleSize={this.toggleSize}
shrink={this.onShrink}
/>
</div>
);
break;
case postCardVisible:
Expand Down
1 change: 0 additions & 1 deletion components/widgets/menu/menu_items/menu_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@

&.MenuItem__with-help {
height: auto;
padding: 0 24px;

.MenuItem__primary-text {
padding: 7px 0 3px;
Expand Down
4 changes: 1 addition & 3 deletions components/widgets/separator/separator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
@import 'utils/module';

.Separator {
height: 2em;
height: 1px;
margin: 0;
position: relative;
text-align: center;
z-index: 0;
pointer-events: none;

z-index: 1;
height: 1px;
margin-bottom: 1em;
margin-top: -1em;

Expand Down