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

Prevent mobile view change on location clear #1085

Merged
merged 14 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
28 changes: 1 addition & 27 deletions lib/components/mobile/location-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import React, { Component } from 'react'
import styled from 'styled-components'

import * as uiActions from '../../actions/ui'
import { ChevronLeft } from '@styled-icons/fa-solid'
import { MobileScreens } from '../../actions/ui-constants'
import { StyledIconWrapper } from '../util/styledIcon'
import LocationField from '../form/connected-location-field'

import MobileContainer from './container'
Expand All @@ -29,14 +27,6 @@ const MobileLocationField = styled(LocationField)`
}
`

const MobileLocationBackButton = styled.button`
background: white;
border: none;
position: absolute;
z-index: 100;
margin-top: 4px;
`

class MobileLocationSearch extends Component {
static propTypes = {
backScreen: PropTypes.number,
Expand All @@ -57,9 +47,6 @@ class MobileLocationSearch extends Component {
const suppressNearby =
otherLocation && otherLocation.category === 'CURRENT_LOCATION'

const backButtonText = intl.formatMessage({
id: 'components.BackToTripPlanner.backToTripPlanner'
})
return (
<MobileContainer>
<MobileNavigationBar
Expand All @@ -73,23 +60,10 @@ class MobileLocationSearch extends Component {
id: 'components.LocationSearch.setOrigin'
})
}
showBackButton
/>
<main tabIndex={-1}>
<div className="location-search mobile-padding">
<MobileLocationBackButton
aria-label={backButtonText}
className="mobile-location-back"
onClick={() =>
// eslint cannot make up its mind on where it wants the bracket to be.
// eslint-disable-next-line prettier/prettier
this.props.setMobileScreen(MobileScreens.SEARCH_FORM)}
title={backButtonText}
>
<StyledIconWrapper>
<ChevronLeft />
</StyledIconWrapper>
</MobileLocationBackButton>

<MobileLocationField
hideExistingValue
inputPlaceholder={
Expand Down
5 changes: 3 additions & 2 deletions lib/components/mobile/mobile.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@
}

.otp .navbar .mobile-back {
background: transparent;
border: none;
position: fixed;
top: 12px;
left: 15px;
left: 7px;
color: white;
amy-corson-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
font-size: 18px;
}
Expand Down
18 changes: 15 additions & 3 deletions lib/components/mobile/navigation-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import styled from 'styled-components'
import * as uiActions from '../../actions/ui'
import { accountLinks, getAuth0Config } from '../../util/auth'
import { ComponentContext } from '../../util/contexts'
import { injectIntl } from 'react-intl'
import { StyledIconWrapper } from '../util/styledIcon'
import AppMenu from '../app/app-menu'
import LocaleSelector from '../app/locale-selector'
Expand All @@ -29,6 +30,7 @@ class MobileNavigationBar extends Component {
extraMenuItems: PropTypes.array,
headerAction: PropTypes.element,
headerText: PropTypes.string,
intl: PropTypes.object,
locale: PropTypes.string,
onBackClicked: PropTypes.func,
setMobileScreen: PropTypes.func,
Expand All @@ -51,21 +53,28 @@ class MobileNavigationBar extends Component {
extraMenuItems,
headerAction,
headerText,
intl,
locale,
showBackButton
} = this.props

const backButtonText = intl.formatMessage({ id: 'common.forms.back' })

return (
<header>
<Navbar className="mobile-navbar-container" fixedTop fluid>
<Navbar.Header>
<Navbar.Brand>
{showBackButton ? (
<div className="mobile-back">
<button
amy-corson-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
aria-label={backButtonText}
className="mobile-back"
title={backButtonText}
>
<StyledIconWrapper onClick={this._backButtonPressed}>
<ArrowLeft />
</StyledIconWrapper>
</div>
</button>
) : (
<AppMenu />
)}
Expand Down Expand Up @@ -122,4 +131,7 @@ const mapDispatchToProps = {
setMobileScreen: uiActions.setMobileScreen
}

export default connect(mapStateToProps, mapDispatchToProps)(MobileNavigationBar)
export default connect(
mapStateToProps,
mapDispatchToProps
)(injectIntl(MobileNavigationBar))
4 changes: 2 additions & 2 deletions percy/percy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ async function executeTest(page, isMobile, isCallTaker) {
// Click the clear button next to it
await page.click('.from-form-control + button')
if (isMobile) {
await page.click('.mobile-location-back')
await page.click('.mobile-back')
}

await page.click('.to-form-control')
await page.waitForTimeout(300)
// Click the clear button next to it
await page.click('.to-form-control + button')
if (isMobile) {
await page.click('.mobile-location-back')
await page.click('.mobile-back')
}

// Fill in new origin
Expand Down
Loading