menu query using include
This commit is contained in:
parent
faee5fcea6
commit
3d0199b2c6
1 changed files with 5 additions and 1 deletions
|
|
@ -45,6 +45,7 @@ async function searchPrompt(allPrompts, tabId, tabType){
|
||||||
// Function to filter and display autocomplete suggestions
|
// Function to filter and display autocomplete suggestions
|
||||||
input.addEventListener('input', function() {
|
input.addEventListener('input', function() {
|
||||||
const query = this.value.trim().toLowerCase();
|
const query = this.value.trim().toLowerCase();
|
||||||
|
console.log(">>>>>>>>>>>> query: " + query);
|
||||||
autocompleteList.innerHTML = ''; // Clear previous suggestions
|
autocompleteList.innerHTML = ''; // Clear previous suggestions
|
||||||
currentFocus = -1; // Reset the highlighted index
|
currentFocus = -1; // Reset the highlighted index
|
||||||
selectedId = null; // Reset the selected ID since input has changed
|
selectedId = null; // Reset the selected ID since input has changed
|
||||||
|
|
@ -59,8 +60,9 @@ async function searchPrompt(allPrompts, tabId, tabType){
|
||||||
|
|
||||||
// Filter data based on the query
|
// Filter data based on the query
|
||||||
const filteredData = allPrompts.filter(item =>
|
const filteredData = allPrompts.filter(item =>
|
||||||
item.label.toLowerCase().startsWith(query)
|
item.label.toLowerCase().includes(query)
|
||||||
);
|
);
|
||||||
|
// console.log(">>>>>>>>>>>>> filteredData: " + JSON.stringify(filteredData));
|
||||||
|
|
||||||
if (filteredData.length === 0) {
|
if (filteredData.length === 0) {
|
||||||
autocompleteList.style.display = 'none';
|
autocompleteList.style.display = 'none';
|
||||||
|
|
@ -77,6 +79,8 @@ async function searchPrompt(allPrompts, tabId, tabType){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// console.log(">>>>>>>>>>>>> filteredData: " + JSON.stringify(filteredData));
|
||||||
|
|
||||||
// Create a div for each filtered result
|
// Create a div for each filtered result
|
||||||
filteredData.forEach(item => {
|
filteredData.forEach(item => {
|
||||||
const itemDiv = document.createElement('div');
|
const itemDiv = document.createElement('div');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue