Skip to content

Commit

Permalink
feat(InputMenu/SelectMenu): allow lazy search (#1705)
Browse files Browse the repository at this point in the history
Co-authored-by: chenying <chenying@addcn.com>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
  • Loading branch information
3 people committed Apr 26, 2024
1 parent ed5c74d commit 7e6ba78
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/content/2.components/input-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ Pass a function to the `search` prop to customize the search behavior and filter

Use the `debounce` prop to adjust the delay of the function.

Use the `searchLazy` prop to control the immediacy of data requests. :u-badge{label="New" class="!rounded-full" variant="subtle"}

::component-example
---
component: 'input-menu-example-search-async'
Expand Down
2 changes: 2 additions & 0 deletions docs/content/2.components/select-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ Pass a function to the `searchable` prop to customize the search behavior and fi

Use the `debounce` prop to adjust the delay of the function.

Use the `searchableLazy` prop to control the immediacy of data requests. :u-badge{label="New" class="!rounded-full" variant="subtle"}

::component-example
---
component: 'select-menu-example-search-async'
Expand Down
6 changes: 6 additions & 0 deletions src/runtime/components/forms/InputMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ export default defineComponent({
type: Array,
default: null
},
searchLazy: {
type: Boolean,
default: false
},
debounce: {
type: Number,
default: 200
Expand Down Expand Up @@ -407,6 +411,8 @@ export default defineComponent({
return child !== null && child !== undefined && String(child).search(new RegExp(query.value, 'i')) !== -1
})
})
}, [], {
lazy: props.searchLazy
})
watch(container, (value) => {
Expand Down
6 changes: 6 additions & 0 deletions src/runtime/components/forms/SelectMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ export default defineComponent({
type: String,
default: 'Search...'
},
searchableLazy: {
type: Boolean,
default: false
},
clearSearchOnClose: {
type: Boolean,
default: () => configMenu.default.clearSearchOnClose
Expand Down Expand Up @@ -470,6 +474,8 @@ export default defineComponent({
return child !== null && child !== undefined && String(child).search(new RegExp(query.value, 'i')) !== -1
})
})
}, [], {
lazy: props.searchableLazy
})
const createOption = computed(() => {
Expand Down

0 comments on commit 7e6ba78

Please sign in to comment.