Skip to content

Commit fe31d60

Browse files
committed
fix(timetable): check that a time cell isn't a frequency start/end time
This fix avoids an NPE when attempting to fetch the pattern stop with an undefined stopTimeIdx. Frequency entries in the timetable do not need stop time objects.
1 parent 8622901 commit fe31d60

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/editor/components/timetable/TimetableGrid.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,17 @@ export default class TimetableGrid extends Component {
287287
updateCellValue
288288
} = this.props
289289

290-
// determine if the value is a time entry
290+
// Determine if the value is a time entry.
291291
if (isTimeFormat(col.type)) {
292292
// make sure stop time isn't null
293293
const splitColKeys = col.key.split('.')
294294
const stopTimeIdx = splitColKeys[1]
295295
const trip = data[rowIndex]
296296
const stopTime = trip.stopTimes[stopTimeIdx]
297-
if (!stopTime) {
298-
// stop time is null. Create new stop time
297+
if (!stopTime && col.key.indexOf('.') !== -1) {
298+
// If stop time is null and there is a '.' in the column key, create a
299+
// new stop time. If there is no '.', this is a frequency start/end
300+
// time, which does not need a new stop time entry.
299301

300302
// get stop id from pattern
301303
const {stopId} = activePattern.patternStops[stopTimeIdx]

0 commit comments

Comments
 (0)