Skip to content

Commit 3fcf83e

Browse files
authored
Merge pull request #1411 from oasisprotocol/mz/mobileSearch
Fix mobile search issues
2 parents e92f373 + 3c176e7 commit 3fcf83e

5 files changed

Lines changed: 21 additions & 8 deletions

File tree

.changelog/1411.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix mobile search issues

src/app/components/AppendMobileSearch/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SearchScope } from '../../../types/searchScope'
77

88
interface AppendMobileSearchProps {
99
action?: ReactNode
10+
enableMobileSearch?: boolean
1011
}
1112

1213
interface AppendMobileSearchLayoutProps {
@@ -41,6 +42,7 @@ export const AppendMobileSearch: FC<PropsWithChildren<AppendMobileSearchProps> &
4142
scope,
4243
children,
4344
action,
45+
enableMobileSearch = true,
4446
}) => {
4547
const { isMobile } = useScreenSize()
4648

@@ -50,7 +52,7 @@ export const AppendMobileSearch: FC<PropsWithChildren<AppendMobileSearchProps> &
5052

5153
{action}
5254

53-
{isMobile && (
55+
{isMobile && enableMobileSearch && (
5456
<SearchWrapper>
5557
<Search scope={scope} variant="expandable" />
5658
</SearchWrapper>

src/app/components/PageLayout/Footer.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import { SearchScope } from '../../../types/searchScope'
1212
import { api, github } from '../../utils/externalLinks'
1313
import { ReopenAnalyticsConsentButton } from 'app/components/AnalyticsConsent'
1414

15-
const FooterBox = styled(Box)(({ theme }) => ({
15+
const FooterBox = styled(Box, {
16+
shouldForwardProp: prop => prop !== 'enableMobileSearch',
17+
})<{ enableMobileSearch: boolean }>(({ theme, enableMobileSearch }) => ({
1618
display: 'flex',
1719
width: '100%',
1820
justifyContent: 'space-between',
19-
padding: theme.spacing(5, 4),
21+
padding: theme.spacing(5, enableMobileSearch ? 4 : 0),
2022
[theme.breakpoints.up('sm')]: {
2123
flex: '0 1 100%',
2224
padding: theme.spacing(5, 0),
@@ -44,9 +46,10 @@ const StyledTypography = styled(Typography)(() => ({
4446
interface FooterProps {
4547
scope?: SearchScope
4648
mobileSearchAction?: ReactNode
49+
enableMobileSearch?: boolean
4750
}
4851

49-
export const Footer: FC<FooterProps> = ({ scope, mobileSearchAction }) => {
52+
export const Footer: FC<FooterProps> = ({ scope, mobileSearchAction, enableMobileSearch = true }) => {
5053
const theme = useTheme()
5154
const { t } = useTranslation()
5255
const { isMobile, isTablet } = useScreenSize()
@@ -56,9 +59,13 @@ export const Footer: FC<FooterProps> = ({ scope, mobileSearchAction }) => {
5659

5760
return (
5861
<footer>
59-
<FooterBox>
62+
<FooterBox enableMobileSearch={enableMobileSearch}>
6063
{isTablet ? (
61-
<AppendMobileSearch scope={scope} action={isMobile && mobileSearchAction}>
64+
<AppendMobileSearch
65+
scope={scope}
66+
action={isMobile && mobileSearchAction}
67+
enableMobileSearch={enableMobileSearch}
68+
>
6269
<StyledTypography variant="footer">
6370
<Box sx={{ whiteSpace: 'nowrap' }}>{t('footer.mobileTitle')} |</Box>
6471
<Box sx={privacyPolicyLinkStyles}>

src/app/components/Search/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ const SearchForm = styled('form', {
5252
display: 'none',
5353
},
5454
[`.${inputAdornmentClasses.positionEnd}`]: {
55+
'button[type="button"]': {
56+
display: 'none',
57+
},
5558
marginLeft: 0,
5659
},
5760
},
@@ -139,7 +142,7 @@ const SearchCmp: FC<SearchProps> = ({ scope, variant, disabled, onFocusChange: o
139142

140143
const onFormSubmit = (e?: FormEvent) => {
141144
e?.preventDefault()
142-
if (value) {
145+
if (value && value !== valueInSearchParams) {
143146
navigate(RouteUtils.getSearchRoute(scope, valueWithoutPrefix))
144147
}
145148
}

src/app/pages/HomePage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export const HomePage: FC = () => {
183183
</Content>
184184

185185
<FooterStyled>
186-
<Footer />
186+
<Footer enableMobileSearch={false} />
187187
</FooterStyled>
188188
</HomepageLayout>
189189
</>

0 commit comments

Comments
 (0)