Fixed #354 - AutoComplete completeOnFocus like PrimeNG
parent
bf114576b1
commit
5136a928b9
|
@ -13,6 +13,7 @@ interface AutoCompleteProps {
|
||||||
minLength?: number;
|
minLength?: number;
|
||||||
delay?: number;
|
delay?: number;
|
||||||
appendTo?: string;
|
appendTo?: string;
|
||||||
|
completeOnFocus?: boolean;
|
||||||
inputStyle?: any;
|
inputStyle?: any;
|
||||||
inputClass?: string;
|
inputClass?: string;
|
||||||
forceSelection?: boolean;
|
forceSelection?: boolean;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<span ref="container" :class="containerClass" aria-haspopup="listbox" :aria-owns="listId" :aria-expanded="overlayVisible" :style="style">
|
<span ref="container" :class="containerClass" aria-haspopup="listbox" :aria-owns="listId" :aria-expanded="overlayVisible" :style="style">
|
||||||
<input ref="input" :class="inputFieldClass" :style="inputStyle" v-bind="$attrs" :value="inputValue" @input="onInput" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @change="onChange"
|
<input ref="input" :class="inputFieldClass" :style="inputStyle" v-bind="$attrs" :value="inputValue" @click="onInputClicked" @input="onInput" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @change="onChange"
|
||||||
type="text" autoComplete="off" v-if="!multiple" role="searchbox" aria-autocomplete="list" :aria-controls="listId">
|
type="text" autoComplete="off" v-if="!multiple" role="searchbox" aria-autocomplete="list" :aria-controls="listId">
|
||||||
<ul ref="multiContainer" :class="multiContainerClass" v-if="multiple" @click="onMultiContainerClick">
|
<ul ref="multiContainer" :class="multiContainerClass" v-if="multiple" @click="onMultiContainerClick">
|
||||||
<li v-for="(item, i) of modelValue" :key="i" class="p-autocomplete-token">
|
<li v-for="(item, i) of modelValue" :key="i" class="p-autocomplete-token">
|
||||||
|
@ -96,6 +96,10 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
completeOnFocus: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
inputClass: null,
|
inputClass: null,
|
||||||
inputStyle: null,
|
inputStyle: null,
|
||||||
class: null,
|
class: null,
|
||||||
|
@ -265,8 +269,11 @@ export default {
|
||||||
this.focus();
|
this.focus();
|
||||||
this.hideOverlay();
|
this.hideOverlay();
|
||||||
},
|
},
|
||||||
onMultiContainerClick() {
|
onMultiContainerClick(event) {
|
||||||
this.focus();
|
this.focus();
|
||||||
|
if(this.completeOnFocus) {
|
||||||
|
this.search(event, '', 'click');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
removeItem(event, index) {
|
removeItem(event, index) {
|
||||||
let removedValue = this.modelValue[index];
|
let removedValue = this.modelValue[index];
|
||||||
|
@ -320,6 +327,12 @@ export default {
|
||||||
query: query
|
query: query
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onInputClicked(event) {
|
||||||
|
if(this.completeOnFocus) {
|
||||||
|
this.search(event, '', 'click');
|
||||||
|
}
|
||||||
|
},
|
||||||
onInput(event) {
|
onInput(event) {
|
||||||
this.inputTextValue = event.target.value;
|
this.inputTextValue = event.target.value;
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,12 @@ export default {
|
||||||
<td>1</td>
|
<td>1</td>
|
||||||
<td>Minimum number of characters to initiate a search.</td>
|
<td>Minimum number of characters to initiate a search.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>completeOnFocus</td>
|
||||||
|
<td>boolean</td>
|
||||||
|
<td>false</td>
|
||||||
|
<td>Whether to run a query when input receives focus.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>delay</td>
|
<td>delay</td>
|
||||||
<td>number</td>
|
<td>number</td>
|
||||||
|
|
Loading…
Reference in New Issue