feat(location): render the search field's open and searching state from the tray

LocationControls presents whether the search field is open and whether a
lookup runs, and the dock renders its expanded and searching classes and
calls toggleSearch(). The lookup, the navigation's settle, Escape and the
location tray's collapse reach the field through the controls
(setSearching, settleSearch, closeSearch) instead of writing its classes.
LocationControls no longer takes searchToggle, LocationSearch takes
setSearching and NavigationController takes settleSearch in place of
searchInput.
This commit is contained in:
Sameh Khamis committed 2026-11-01 13:53:31 -08:00
1 parent b4ee2321cf
commit 0949f6a776
18 files changed
+238 -83

No files matched your search

+23 -6
View File
@@ -115,11 +115,14 @@ export class LocationNavigation {
_initLocationBar() {
const { CITY_POIS, searchAndFlyTo, LocationSearch } = this.services;
// An open field stays open in the new controls.
const searchExpanded = Boolean(this._locationControls?.searchExpanded);
this._locationControls?.destroy();
this._locationLookupUnsubscribe?.();
this._locationLookup?.destroy();
this._locationLookup = new LocationSearch({
input: this._locationSearch,
setSearching: (active) => this._locationControls?.setSearching(active),
begin: () => this._beginDeferredNavigation('location'),
isCurrent: (generation) =>
!this._disposed && generation === this._navigationGeneration,
@@ -135,15 +138,9 @@ export class LocationNavigation {
},
onError: (error) => console.error('[Search] Geocoding failed:', error),
});
this._locationLookupUnsubscribe = this._locationLookup.subscribe(
({ initial, change }) => {
this._locationState.publish(initial ? { type: 'reset' } : change);
},
);
this._locationControls = new LocationControls({
elements: {
search: this._locationSearch,
searchToggle: this._searchToggle,
},
publish: (view) => this._publishLocation?.(view),
cities: CITY_POIS,
@@ -153,7 +150,15 @@ export class LocationNavigation {
onSearch: (query) => this._locationLookup.run(query),
onSearchEdit: () => this._setLocationSearchError(null),
onReset: () => this.resetToGlobeView(),
searchExpanded,
});
// The new lookup's reset settles a replaced lookup's search through the
// new controls, so it subscribes once they are in place.
this._locationLookupUnsubscribe = this._locationLookup.subscribe(
({ initial, change }) => {
this._locationState.publish(initial ? { type: 'reset' } : change);
},
);
this._connectLocation?.(this._locationControls);
this._connectGlobeReset?.(this._locationControls);
}
@@ -412,6 +417,18 @@ export class LocationNavigation {
return resetPromise;
}
/** Settle the search field once its lookup has (LocationControls.settleSearch). */
settleSearch(options) {
this._locationControls?.settleSearch(options);
}
/** Close the search field; with `ifOpen`, only when it is open. */
closeSearch({ ifOpen = false } = {}) {
const controls = this._locationControls;
if (ifOpen && !controls?.searchExpanded) return;
controls?.closeSearch();
}
/** Revoke callbacks and settle owned camera work before the viewer is released. */
destroy() {
if (this._disposed) return;