diff --git a/src/views/autocomplete/AutoCompleteDemo.vue b/src/views/autocomplete/AutoCompleteDemo.vue index 364f4fcdb..dc9ee22fe 100755 --- a/src/views/autocomplete/AutoCompleteDemo.vue +++ b/src/views/autocomplete/AutoCompleteDemo.vue @@ -11,10 +11,10 @@
AutoComplete uses v-model for two-way binding, requires a list of suggestions and a complete method to query for the results. The complete method gets the query text as event.query property and should update the suggestions with the search results. Example below connects to a remote datasource to fetch the results;
-<AutoComplete v-model="selectedCountry" :suggestions="filteredCountriesBasic" @complete="searchCountry($event)" field="name" />
+<AutoComplete v-model="selectedCountry" :suggestions="filteredCountriesBasic" @complete="searchCountry($event)" optionLabel="name" />
@@ -54,16 +54,16 @@ export default {
Multiple Mode
Multiple mode is enabled using multiple property to select more than one value from the autocomplete. In this case, value reference should be an array.
-<AutoComplete :multiple="true" v-model="selectedCountries" :suggestions="filteredCountriesMultiple" @complete="searchCountryMultiple($event)" field="name" />
+<AutoComplete :multiple="true" v-model="selectedCountries" :suggestions="filteredCountriesMultiple" @complete="searchCountryMultiple($event)" optionLabel="name" />
Objects
- AutoComplete can also work with objects using the field property that defines the label to display
+
AutoComplete can also work with objects using the optionLabel property that defines the label to display
as a suggestion. The value passed to the model would still be the object instance of a suggestion.
Here is an example with a Country object that has name and code fields such as {name:"United States",code:"USA"}.
-<AutoComplete field="label" v-model="selectedCountry" :suggestions="filteredCountriesBasic" @complete="searchCountryBasic($event)" />
+<AutoComplete optionLabel="label" v-model="selectedCountry" :suggestions="filteredCountriesBasic" @complete="searchCountryBasic($event)" />
@@ -108,7 +108,7 @@ export default {
<AutoComplete v-model="selectedCity" :suggestions="filteredCities" @complete="searchCity($event)"
- field="label" optionGroupLabel="label" optionGroupChildren="items"></AutoComplete>
+ optionLabel="label" optionGroupLabel="label" optionGroupChildren="items"></AutoComplete>
@@ -134,7 +134,7 @@ export default {
Any property such as name and placeholder are passed to the underlying input element. Following are the additional properties to configure the component.
+Any property of HTMLDivElement are passed to the main container element. Following are the additional properties to configure the component.
field | any | null | -Property name or getter function of a suggested object to resolve and display. | +Property name or getter function of a suggested object to resolve and display. *Deprecated since v3.16.0. Use 'optionLabel' property instead. | + +||
optionLabel | +string | function | +null | +Property name or getter function to use as the label of an option. | +|||
optionDisabled | +string | function | +null | +Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. | |||
optionGroupLabel | @@ -198,7 +210,7 @@ export default {autoHighlight | boolean | false | -Highlights automatically the first item of the dropdown to be selected. | +Highlights automatically the first item of the dropdown to be selected. *Deprecated since v3.16.0. | |
multiple | @@ -206,18 +218,30 @@ export default {false | Specifies if multiple values can be selected. | ||||
placeholder | +string | +null | +Default text to display when no option is selected. | +|||
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +|||
dataKey | +string | +null | +A property to uniquely identify an option. | +|||
minLength | number | 1 | Minimum number of characters to initiate a search. | |||
completeOnFocus | -boolean | -false | -Whether to run a query when input receives focus. | -|||
delay | number | @@ -238,6 +262,18 @@ export default {When present, autocomplete clears the manual input if it does not match of the suggestions to force only accepting values from the suggestions. | ||||
completeOnFocus | +boolean | +false | +Whether to run a query when input receives focus. | +|||
inputId | +string | +null | +Identifier of the underlying input element. | +|||
inputStyle | any | @@ -251,16 +287,16 @@ export default {Style class of the input field. | ||||
style | -any | +inputProps | +object | null | -Style class of the component input field. | +Uses to pass all properties of the HTMLInputElement/HTMLSpanElement to the focusable input element inside the component. |
class | -string | +panelStyle | +any | null | -Inline style of the component. | +Inline style of the overlay panel. |
panelClass | @@ -268,6 +304,12 @@ export default {null | Style class of the overlay panel. | ||||
panelProps | +object | +null | +Uses to pass all properties of the HTMLDivElement to the overlay panel. | +|||
loadingIcon | string | @@ -279,14 +321,67 @@ export default {object | null | Whether to use the virtualScroller feature. The properties of |
+ ||
autoOptionFocus | +boolean | +true | +Whether to focus on the first visible or selected element when the overlay panel is shown. | +|||
searchLocale | +string | +undefined | +Locale to use in searching. The default locale is the host environment's current locale. | +|||
searchMessage | +string | +{0} results are available | +Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration. | +|||
selectionMessage | +string | +{0} items selected | +Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration. | +|||
emptySelectionMessage | +string | +No selected item | +Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration. | +|||
emptySearchMessage | +string | +No results found | +Text to be displayed when filtering does not return any results. Defaults to value from PrimeVue locale configuration. | +|||
tabindex | +number | +0 | +Index of the element in tabbing order. | +|||
ariaLabel | +string | +null | +Defines a string value that labels an interactive element. | +|||
ariaLabelledby | +string | +null | +Establishes relationships between the component and label(s) where its value should be one or more element IDs. |
Any valid event such as focus, blur and input are passed to the underlying input element. Following are the additional events to configure the component.
-complete | -
- event.originalEvent: Browser event - event.query: Value to search with - |
- Callback to invoke to search for suggestions. | +change | +event.originalEvent: Original event + event.value: Selected option value |
+ Callback to invoke on value change. | +
focus | +event | +Callback to invoke when the component receives focus. | +|||
blur | +event | +Callback to invoke when the component loses focus. | |||
item-select | @@ -328,6 +431,34 @@ export default {clear | - | Callback to invoke when input is cleared by the user. | +||
complete | +
+ event.originalEvent: Browser event + event.query: Value to search with + |
+ Callback to invoke to search for suggestions. | +|||
before-show | +- | +Callback to invoke before the overlay is shown. | +|||
before-hide | +- | +Callback to invoke before the overlay is hidden. | +|||
show | +- | +Callback to invoke when the overlay is shown. | +|||
hide | +- | +Callback to invoke when the overlay is hidden. |
Value to describe the component can either be provided via label tag combined with inputId prop or using aria-labelledby, aria-label props. The input element has combobox role + in addition to aria-autocomplete, aria-haspopup and aria-expanded attributes. The relation between the input and the popup is created with aria-controls and aria-activedescendant attribute is used + to instruct screen reader which option to read during keyboard navigation within the popup list.
+In multiple mode, chip list uses listbox role with aria-orientation set to horizontal whereas each chip has the option role with aria-label set to the label of the chip.
+The popup list has an id that refers to the aria-controls attribute of the input element and uses listbox as the role. Each list item has option role and an id to match the aria-activedescendant of the input element.
+ +
+<label for="ac1">Username</label>
+<AutoComplete inputId="ac1" />
+
+<span id="ac2">Email</span>
+<AutoComplete aria-labelledby="ac2" />
+
+<AutoComplete aria-label="City" />
+
+
+
+ Key | +Function | +
---|---|
tab | +Moves focus to the autocomplete element. | +
any printable character | +Opens the popup and moves focus to the first option. | +
Key | +Function | +
---|---|
tab | +Moves focus to the next focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. | +
shift + tab | +Moves focus to the previous focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. | +
enter | +Selects the focused option and closes the popup, then moves focus to the autocomplete element. | +
space | +Selects the focused option and closes the popup, then moves focus to the autocomplete element. | +
escape | +Closes the popup, then moves focus to the autocomplete element. | +
down arrow | +Moves focus to the next option, if there is none then visual focus does not change. | +
up arrow | +Moves focus to the previous option, if there is none then visual focus does not change. | +
alt + up arrow | +Selects the focused option and closes the popup, then moves focus to the autocomplete element. | +
left arrow | +Removes the visual focus from the current option and moves input cursor to one character left. | +
right arrow | +Removes the visual focus from the current option and moves input cursor to one character right. | +
home | +Moves input cursor at the end, if not then moves focus to the first option. | +
end | +Moves input cursor at the beginning, if not then moves focus to the last option. | +
pageUp | +Jumps visual focus to first option. | +
pageDown | +Jumps visual focus to last option. | +
Key | +Function | +
---|---|
backspace | +Deletes the previous chip if the input field is empty. | +
left arrow | +Moves focus to the previous chip if available and input field is empty. | +
Key | +Function | +
---|---|
left arrow | +Moves focus to the previous chip if available. | +
right arrow | +Moves focus to the next chip, if there is none then input field receives the focus. | +
backspace | +Deletes the chips and adds focus to the input field. | +
None.
@@ -442,10 +742,10 @@ export default {