Skip to content

Commit 6c5c9ab

Browse files
committed
ui(tour): show "Nearest stop" only once a departure is set
"Nearest stop" extends a tour from its frontier (the last stop, or the departure when empty), so it's meaningless without a departure — it would just invent a random origin. Hide it until an origin is chosen, and re-evaluate on live form changes so it appears the moment a departure is typed or filled. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GjYKzVUaZR1Awer3K9BTXW
1 parent 5159b40 commit 6c5c9ab

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/app.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ function liveUpdate(): void {
474474
store.updateUrl(query);
475475
settings = { ...settings, card: query.card };
476476
store.saveSettings(settings);
477+
refreshNearestBtn(); // a freshly typed (or cleared) departure flips its relevance
477478
runSearch();
478479
}
479480

@@ -1039,8 +1040,15 @@ function updateFieldVisibility(): void {
10391040
refs.citiesField.style.display = query.mode === "tour" ? "" : "none";
10401041
refs.stayField.style.display = query.mode === "tour" ? "" : "none";
10411042
refs.maxKmField.style.display = query.mode === "tour" ? "" : "none";
1042-
// "Nearest stop" sits beside "Surprise me" but only makes sense for a tour.
1043-
nearestBtnEl?.toggleAttribute("hidden", query.mode !== "tour");
1043+
refreshNearestBtn();
1044+
}
1045+
1046+
/**
1047+
* "Nearest stop" extends a tour from its frontier, so it only makes sense in tour
1048+
* mode once there's a departure to extend from — hidden until then.
1049+
*/
1050+
function refreshNearestBtn(): void {
1051+
nearestBtnEl?.toggleAttribute("hidden", !(query.mode === "tour" && Boolean(query.origin)));
10441052
}
10451053

10461054
function buildLayout(root: HTMLElement): void {

0 commit comments

Comments
 (0)