Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tag search #3747

Merged
merged 2 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions src/components/NcSelect/NcSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ export default {
}),
},

/**
* Sets the maximum number of options to display in the dropdown list
*/
limit: {
type: Number,
default: null,
},

/**
* Disable the component
*
Expand Down Expand Up @@ -669,7 +677,8 @@ export default {
/**
* Key of the displayed label for object options
*
* Defaults to `'label'`
* Defaults to the internal vue-select string documented at the link
* below
*
* Enabling `userSelect` will automatically set this to `'displayName'`
* unless this prop is set explicitly
Expand Down Expand Up @@ -855,35 +864,29 @@ export default {
if (this.filterBy !== null) {
return this.filterBy
}

if (this.userSelect) {
return (option, label, search) => {
return (`${label} ${option.subtitle}` || '')
.toLocaleLowerCase()
.indexOf(search.toLocaleLowerCase()) > -1
}
}
return null
return VueSelect.props.filterBy.default
},

localLabel() {
if (this.label !== null) {
return this.label
}

if (this.userSelect) {
return 'displayName'
}
return 'label'
return VueSelect.props.label.default
},

propsToForward() {
const {
// Custom overrides of vue-select props
calculatePosition,
filterBy,
label,
// Props handled by the component itself
// Props handled by this component
noWrap,
placement,
userSelect,
Expand All @@ -893,14 +896,12 @@ export default {

const propsToForward = {
...initialPropsToForward,
// Custom overrides of vue-select props
calculatePosition: this.localCalculatePosition,
filterBy: this.localFilterBy,
label: this.localLabel,
}

if (this.localFilterBy) {
propsToForward.filterBy = this.localFilterBy
}

return propsToForward
},
},
Expand Down
19 changes: 15 additions & 4 deletions src/components/NcSelectTags/NcSelectTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export default {
```

### Custom filter
Because of compatibility reasons only 5 tag entries are shown by default. If you want to show all available tags set the `optionsFilter` function-prop to `null`:
Because of compatibility reasons only 5 tag entries are shown by default. If you want to show all available tags set the `limit` prop to `null`:
```vue
<template>
<div class="wrapper">
<NcSelectTags v-model="value" :options-filter="null" />
<NcSelectTags v-model="value" :limit="null" />
{{ value }}
</div>
</template>
Expand Down Expand Up @@ -192,6 +192,17 @@ export default {
},
},

/**
* Sets the maximum number of tags to display in the dropdown list
*
* Because of compatibility reasons only 5 tag entries are shown by
* default
*/
limit: {
type: Number,
default: 5,
},

/**
* Allow selection of multiple options
*
Expand All @@ -210,7 +221,7 @@ export default {
*/
optionsFilter: {
type: Function,
default: (_element, index) => index < 5,
default: null,
},

/**
Expand Down Expand Up @@ -280,7 +291,7 @@ export default {

propsToForward() {
const {
// Props handled by the component itself
// Props handled by this component
optionsFilter,
// Props to forward
...propsToForward
Expand Down