DAutocomplete
DAutocomplete - A type-safe wrapper around Bootstrap Vue Next’s BAutocomplete component. A text input with a filtered dropdown of suggestions (typeahead / combobox). Pass options and bind v-model; supports multiple selection and a custom filterFunction.
Live Examples
Country
Start typing to filter the list.
Selected: —
Searchable single-select with a null option
null-option pins a selectable "no selection" row to the top of the list. It is never filtered out as you type, and selecting it sets the model back to null. Option values round-trip unchanged — the numeric ids below come back as numbers.
Selected id: —(type: object)
Searching a server as you type
provider asks for the matching options once typing pauses, here from a pretend server that takes 400 ms. Type fil, then keep typing: only the latest result is listed, and the earlier call is aborted.
Selected id: —(calls so far: 0)
Extra props (beyond Bootstrap Vue Next)
DAutocomplete adds one prop on top of BAutocomplete’s API to make it a
complete searchable single-select:
| Prop | Type | Default | Description |
|---|---|---|---|
null-option | boolean | string | false | Prepend a pinned, never-filtered, selectable “no selection” row whose value is null. true uses the label None; a string sets a custom label. Selecting it sets the model to null (which reads as no selection — the clear ✕ hides and the placeholder shows). When a custom filterFunction is supplied it composes: the null option stays pinned and your filter runs on the remaining options. |
Option values round-trip unchanged — a numeric value comes back as a
number, so there is no String()/Number() dance. (DXTable’s string-value
column filters are unaffected; it builds its own “All” option and does not use
null-option.)
Options may arrive after the value. Bind the value first and load the
options later (a filter seeded from the URL while its list is fetched): when
the options change and one matches the value, the input shows that option’s
label instead of the raw value. A search the user is typing is never
overwritten, and if you bind v-model:search yourself the text is yours.
Searching a server as you type
A list too big to download (thousands of product lines) is searched where it
lives. Pass provider, a function (term, signal) => Promise<options>, and
leave options out or use it as a seed:
<DAutocomplete
v-model="productLineId"
:provider="searchProductLines"
placeholder="Add a product to this order…"
/>
const searchProductLines = async (term: string, signal: AbortSignal) => {
const response = await fetch(`/api/product-lines?filter[name]=${encodeURIComponent(term)}`, { signal });
const { data } = await response.json();
return data.map((line) => ({ value: line.id, text: line.name }));
};
- The provider is called with the trimmed text once typing has paused for
provider-debouncems (default 250). An empty term makes no call and clears the results. - Only the latest call’s result is listed. Typing a newer term aborts the
call in flight through its
signal, and a call that ignores the signal and resolves late is dropped, so a slow early response cannot overwrite a later one. - Bootstrap Vue Next’s substring filter is bypassed: the server has already
filtered. A
filterFunctionis ignored in this mode. optionsstays in the list alongside the results (deduplicated by value), so a value bound before any search has run can be labelled by passing its option there.- While the list is empty it reads Type to search, Searching…,
No matches or Search failed (a rejected promise, logged; an abort is
not a failure). Fill the
emptyslot to show something else. The root element carriesaria-busy="true"during a call. - Only typing is a search. The text Bootstrap Vue Next writes itself (the chosen option’s label on selection, blur or Escape; the label or raw value of a bound model) never asks the provider.
- With
null-optionthe list is never empty, so the status texts do not show;aria-busystill does.
The name follows DXTable’s provider, a function that supplies rows.
search is Bootstrap Vue Next’s prop for the input’s own text and is
unchanged.
Slots
This component forwards all slots dynamically from the underlying Bootstrap Vue Next component.
Bootstrap Vue Next Wrapper
This is a lightweight type-safe wrapper around the corresponding Bootstrap Vue Next component. It provides API stability and forwards all props, events, and slots.
For complete API documentation (props, events, methods), refer to the Bootstrap Vue Next documentation.