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

+33 -2
View File
@@ -168,7 +168,6 @@ test('the ORBIT indicator sits on the body while offered and lights while orbiti
const controls = new LocationControls({
elements: {
search: $('#location-search'),
searchToggle: $('#search-toggle'),
},
cities: {},
getExpandedCity: () => null,
@@ -209,7 +208,6 @@ test('the location tray renders what LocationControls publishes', async (t) => {
const controls = new LocationControls({
elements: {
search: $('#location-search'),
searchToggle: $('#search-toggle'),
},
cities: {
paris: { name: 'Paris', pois: [{ name: 'Louvre' }, { name: 'Eiffel' }] },
@@ -455,3 +453,36 @@ test('closing a sheet returns focus to its tab once the tab bar shows it closed'
);
assert.equal($('#mobile-sheet-backdrop').hidden, false);
});
test('the search toggle opens the field, and a lookup marks it', async (t) => {
const { $, pinia } = fixture(t);
const store = useLocationStore(pinia);
const controls = new LocationControls({
elements: { search: $('#location-search') },
cities: {},
getExpandedCity: () => null,
onCity() {},
onPoi() {},
onSearch() {},
onReset() {},
publish: (view) => store.publish(view),
requestFrame() {},
cancelFrame() {},
});
t.after(() => controls.destroy());
store.connect(controls);
await nextTick();
const field = $('#location-search');
assert.equal(field.classList.contains('expanded'), false);
$('#search-toggle').click();
await nextTick();
assert.equal(field.classList.contains('expanded'), true);
assert.equal(document.activeElement, field);
controls.setSearching(true);
await nextTick();
assert.equal(field.classList.contains('searching'), true);
controls.settleSearch();
await nextTick();
assert.equal(field.classList.contains('searching'), false);
assert.equal(field.classList.contains('expanded'), false);
});