Skip to content

Commit

Permalink
Merge pull request #1023 from opentripplanner/fix-itin-clicks
Browse files Browse the repository at this point in the history
Fix unclickable itinerary
  • Loading branch information
miles-grant-ibigroup authored Oct 5, 2023
2 parents dce2cec + 391a36a commit d0f3297
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
25 changes: 21 additions & 4 deletions __tests__/util/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,32 @@ describe('util > ui', () => {
ItineraryView.LIST
)
})
it('returns a full itinerary view if URL contains ui_activeItinerary', () => {
it('returns a full itinerary view if URL contains ui_activeItinerary that is not -1', () => {
expect(getItineraryView({ ui_activeItinerary: 2 })).toBe(
ItineraryView.FULL
)
})
it('returns an itinerary list view if URL contains ui_activeItinerary=-1 regardless of ui_itineraryView', () => {
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: ItineraryView.FULL
})
).toBe(ItineraryView.LIST)
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: ItineraryView.LEG
})
).toBe(ItineraryView.LIST)
})
it('returns the specified view mode when set in URL', () => {
expect(getItineraryView({ ui_itineraryView: 'leg' })).toBe(
ItineraryView.LEG
)
expect(
getItineraryView({
ui_activeItinerary: 0,
ui_itineraryView: ItineraryView.LEG
})
).toBe(ItineraryView.LEG)
})
})
})
2 changes: 2 additions & 0 deletions lib/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export function updateOtpUrlParams(state, searchId) {
params.ui_activeSearch = searchId
// Assumes this is a new search and the active itinerary should be reset.
params.ui_activeItinerary = -1
// At the same time, reset/delete the ui_itineraryView param.
params.ui_itineraryView = undefined
if (config.itinerary?.showFirstResultByDefault) {
dispatch(setVisibleItinerary({ index: 0 }))
}
Expand Down
4 changes: 4 additions & 0 deletions lib/util/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export function getItineraryView({
ui_itineraryView
}: UrlParams): ItineraryView {
return (
((ui_activeItinerary === null ||
ui_activeItinerary === undefined ||
`${ui_activeItinerary}` === '-1') &&
ItineraryView.LIST) ||
ui_itineraryView ||
(isDefinedAndNotEqual(ui_activeItinerary, -1) && ItineraryView.FULL) ||
ItineraryView.LIST
Expand Down

0 comments on commit d0f3297

Please sign in to comment.