# SearchPill

The floating search pill: a 48px pill holding an ARIA 1.2 combobox and a
Search button, with the results in a listbox just below it. It must be
rendered inside a `FocusRegistryProvider`, which it tells where the input is
so that closing the search surface can return focus to it.

This is a function exported by `@mapcairn/map`, checked against version 0.2.0.

## Signature

```ts
import { SearchPill } from "@mapcairn/map";
 
function SearchPill(input: SearchPillProps): JSX.Element;
```

## Description

The geocoder searches only on submit (Enter, or the Search button), never
as the user types, because the OpenStreetMap Foundation's Nominatim policy
forbids client-side autocomplete. Editing the text hides any results for
the old text. When the host supplies a suggestion provider, the listbox also
holds suggestions for the text as it is typed (see [`useSuggestions`](https://docs.mapcairn.com/api/map/useSuggestions.md)):
they are the same options with the same keys, picking one goes straight to
its place with no second lookup, and Enter with none highlighted still
submits the text to the geocoder. When the provider is missing or failing,
typing shows nothing and Enter works as it always did.

Keyboard, following the WAI-ARIA Authoring Practices "list" combobox, with
the listbox filled by suggestions or by a submitted search:
- Results never take focus: the input keeps focus and
 `aria-activedescendant` names the active option.
- ArrowDown and ArrowUp move the active option, wrapping at the ends, and
 open a closed list that has something to show. They are the only keys
 that move between options.
- Home and End are left to the browser, so they move the caret as in any
 text field. When an option is active they also hand visual focus back to
 the text box (the active option is cleared), as the pattern describes.
- Enter selects the active option. With no active option it submits the
 text, or reopens the list when it already holds that text's results. A
 search that finds exactly one place goes to it without a list: the box
 shows its label, the map moves and the announcement names the place.
 Several results open the list as before.
- Escape closes the list. With the list already closed, a second Escape
 clears the text, and a third reaches the page (closing the surface).

Selecting a result or a suggestion fills the box with its label without
searching again, and suggests nothing more for that label.

## Parameters

- `{ onSelect, getBias, onFocus, onBlur, }`
- `input` (`SearchPillProps`)

## Returns

`JSX.Element`

## Remarks

The panel is in normal flow below the pill; the chrome slot that
 holds this component decides where both sit. Text states in the panel
 ("Searching...", "Nothing matched that search.", the unavailable message)
 carry no live-region role, because the announcer speaks the outcome.

## See also

- [`SearchPillProps`](https://docs.mapcairn.com/api/map/SearchPillProps.md)

Source: [packages/map/src/tools/SearchPill/SearchPill.tsx:106](https://github.com/MapCairn/mapcairn/blob/main/packages/map/src/tools/SearchPill/SearchPill.tsx#L106)
