Search
Enter at least two characters without personal information.

    LibraryArticles & FAQ Your projectRequest a quote
    LanguageEN
    Practical guides

    Design autocomplete for selecting a value

    Autocomplete suggests values while someone types. It can help select a town or product from a long catalogue. Its usefulness also depends on data quality and what happens when no suggestion meets the need.

    Go to the method

    Phone presenting suggestions beside a map
    AI-generated illustration

    Define what input means

    Decide whether the field accepts free text or requires a catalogue entry. Explain this near the label. Typing a string is not automatically selection: a town identifier needs the chosen record, not merely its displayed name.

    Disambiguate repeated names with a useful detail, such as department, without collecting unnecessary information. Define accent, hyphen and alternate-name handling from the catalogue. Do not silently select the first suggestion when several remain plausible.

    Allow exploration before acceptance

    The W3C combobox pattern describes input associated with suggestions and interactions to explore, accept or leave them. Communicate expansion and the active option. Standard text editing should remain available.

    Keep a highlighted suggestion distinct from an accepted value. When the list closes, the person should understand what will be submitted. Test keyboard selection, editing after selection and leaving the field without accepting an option.

    For an editable combobox with a list and manual selection, keep DOM focus in the input. aria-activedescendant can reference the explored option; it must identify an element that actually exists in the current list. Update aria-expanded when opening and closing. The visually active option, typed text and accepted business identifier are different states: record each separately during testing.

    Specify the manual-selection contract: exploring a suggestion does not commit it; Enter accepts it, while Escape here closes the list without clearing input. This choice does not describe every combobox variant: some automatically accept a suggestion when the field loses focus. After editing an already selected label, invalidate the old identifier until a new match is confirmed if the form requires a catalogue entry.

    Scroll the table horizontally to read every column. With a keyboard, focus the table area and use the arrow keys.

    Manual autocomplete: explore without committing by mistake
    Action in the chosen variantState to checkBusiness submission
    Explore with arrow keysThe active option changes; DOM focus stays in the input.This movement alone confirms no new identifier.
    Accept with EnterThe label and identifier match the accepted option.The chosen identifier becomes the value for server validation.
    Dismiss with EscapeThe list closes; this variant preserves typed input.No additional suggestion is accepted.
    Edit text after selectionThe old identifier is not attached to changed text without validation.A catalogue choice is still required if the field demands it.
    • W3C APG : Combobox

      Guidance consulted on 22 October 2026; scope: editable list with manual selection and no clearing on Escape.

    Handle network and catalogue changes

    A slow response for older input must not replace suggestions for newer text. Waiting, no match and service failure are different states. Provide another way forward when autocomplete is a convenience rather than an essential dependency.

    An entry withdrawn between selection and submission needs server validation and an actionable response. Preserve other fields while the person selects again. Where results are limited, ask for a more specific search rather than presenting a partial list as complete.

    Example: towns with the same name

    Educational example: two suggestions share a name but belong to different departments. Each shows both details; submission uses the chosen identifier. Testing selects the second entry, edits the text and checks that the old identifier is not accidentally retained. Another test interrupts the network and checks recovery.

    Stop an earlier search from replacing suggestions for the current input.

    Synthetic case: someone types ‘museum’, then ‘music’, on a slow connection. Delay the first response in a test environment. Cancel the previous operation and also check the active search identifier before displaying results. Cancelling in the browser does not prove that the server stopped processing the request.

    • Only the latest input’s suggestions appear; cancellation does not trigger a misleading failure message.
    • MDN AbortController

      API for cancelling asynchronous operations, including Fetch requests and consumption of their responses.

    Reference documents

    Content updated on

    Acceptance matrix to adapt to your project

    These proposed checks use synthetic cases. Decide the required behaviour with the team, record the result and assign unresolved gaps before release.

    Scroll the table horizontally to read every column. With a keyboard, focus the table area and use the arrow keys.

    Test cases, expected outcomes and useful evidence
    CaseExpected outcomeEvidence to retain
    Repeated nameSuggestions can be distinguishedTwo synthetic namesakes, distinguishing labels and identifier actually assigned to the selection.
    Responses out of orderOnly current suggestions appearTest request sequence
    Editing after selectionText and identifier stay consistentDisplayed and submitted values
    No matchAn explanation and next step existMessage and next action

    Frequently asked questions

    Why not automatically choose the first result?

    A suggestion may not be the person’s choice. Silent selection can submit the wrong town or product.

    Does visible text identify a record?

    Not if names repeat or change. Use a stable reference and check its consistency with what is shown.

    Does a short list need autocomplete?

    A native select or visible choices may be simpler. Compare effort and frequency before building custom suggestions.