Skip to content

Active search not aligned with current query params in form when back button pressed #322

Open
@landonreed

Description

@landonreed

It might be considered a bug that we are not overwriting the time setting when the back button is pressed in order to have the query settings match the active search. Currently, the current query is kept separate from the active search, even if the active search is showing results for a different set of query params. Let's consider a user making a transit search

  1. First the user searches with a leave time of 9am (search A)
  2. The user changes the time to 10am and clicks Plan trip (search B)
  3. Next, the user clicks the back button, which causes the active search to switch from B to A, but the query time in the form still shows 10am.

This may require some code in the componentDidUpdate method similar to the below. Or, perhaps we should introduce a helper method to get the currentQuery that checks the searches list in the app state before defaulting to state.otp.currentQuery.

// componentDidUpdate for call-taker/date-time-options.js
if (time !== prevProps.time) {
  const date = moment().startOf('day').format('YYYY-MM-DD')
  const parsedTime = moment(date + 'T' + this.state.timeInput, SUPPORTED_TIME_FORMATS)
  const dateTime = moment(`${date} ${time}`)
  if (parsedTime.format('H:mm') !== dateTime.format('H:mm')) {
    this._updateTimeInput(dateTime)
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions