Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile: Fixes #11130: Fix regression: Search screen not hidden when cached for search result navigation #11131

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
7 changes: 7 additions & 0 deletions packages/app-mobile/components/global-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type ThemeStyle = BaseTheme & typeof baseStyle & {
headerStyle: TextStyle;
headerWrapperStyle: ViewStyle;
rootStyle: ViewStyle;
hiddenRootStyle: ViewStyle;
keyboardAppearance: 'light'|'dark';
};

Expand Down Expand Up @@ -87,6 +88,11 @@ function extraStyles(theme: BaseTheme) {
backgroundColor: theme.backgroundColor,
};

const hiddenRootStyle: ViewStyle = {
...rootStyle,
flex: 0.001, // This is a bit of a hack but it seems to work fine - it makes the component invisible but without unmounting it
};

return {
marginRight: baseStyle.margin,
marginLeft: baseStyle.margin,
Expand All @@ -101,6 +107,7 @@ function extraStyles(theme: BaseTheme) {
headerStyle,
headerWrapperStyle,
rootStyle,
hiddenRootStyle,

keyboardAppearance: theme.appearance,
color5: theme.color5 ?? theme.backgroundColor4,
Expand Down
9 changes: 1 addition & 8 deletions packages/app-mobile/components/screens/Notes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,7 @@ class NotesScreenComponent extends BaseScreenComponent<Props, State> {
const parent = this.parentItem();
const theme = themeStyle(this.props.themeId);

const rootStyle = {
flex: 1,
backgroundColor: theme.backgroundColor,
};

if (!this.props.visible) {
rootStyle.flex = 0.001; // This is a bit of a hack but it seems to work fine - it makes the component invisible but without unmounting it
}
const rootStyle = this.props.visible ? theme.rootStyle : theme.hiddenRootStyle;

const title = parent ? parent.title : null;
if (!parent) {
Expand Down
12 changes: 7 additions & 5 deletions packages/app-mobile/components/screens/SearchScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Dispatch } from 'redux';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import IconButton from '../../IconButton';
import SearchResults from './SearchResults';
import AccessibleView from '../../accessibility/AccessibleView';

interface Props {
themeId: number;
Expand All @@ -21,7 +22,7 @@ interface Props {
ftsEnabled: number;
}

const useStyles = (theme: ThemeStyle) => {
const useStyles = (theme: ThemeStyle, visible: boolean) => {
return useMemo(() => {
return StyleSheet.create({
body: {
Expand All @@ -46,13 +47,14 @@ const useStyles = (theme: ThemeStyle) => {
paddingRight: theme.marginRight,
backgroundColor: theme.backgroundColor,
},
rootStyle: visible ? theme.rootStyle : theme.hiddenRootStyle,
});
}, [theme]);
}, [theme, visible]);
};

const SearchScreenComponent: React.FC<Props> = props => {
const theme = themeStyle(props.themeId);
const styles = useStyles(theme);
const styles = useStyles(theme, props.visible);

const [query, setQuery] = useState(props.query);

Expand All @@ -79,7 +81,7 @@ const SearchScreenComponent: React.FC<Props> = props => {
}, [props.dispatch]);

return (
<View style={theme.rootStyle}>
<AccessibleView style={styles.rootStyle} inert={!props.visible}>
<ScreenHeader
title={_('Search')}
folderPickerOptions={{
Expand Down Expand Up @@ -115,7 +117,7 @@ const SearchScreenComponent: React.FC<Props> = props => {
onHighlightedWordsChange={onHighlightedWordsChange}
/>
</View>
</View>
</AccessibleView>
);
};

Expand Down
Loading