mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Limit search input to first character matching when only one character is typed
This commit is contained in:
parent
2ee0ae1f9e
commit
5293349785
@ -154,8 +154,33 @@ class SeriesSearchInput extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSuggestionsFetchRequested = ({ value }) => {
|
onSuggestionsFetchRequested = ({ value }) => {
|
||||||
const fuse = new Fuse(this.props.series, fuseOptions);
|
const { series } = this.props;
|
||||||
const suggestions = fuse.search(value);
|
let suggestions = [];
|
||||||
|
|
||||||
|
if (value.length === 1) {
|
||||||
|
suggestions = series.reduce((acc, s) => {
|
||||||
|
if (s.firstCharacter === value.toLowerCase()) {
|
||||||
|
acc.push({
|
||||||
|
item: s,
|
||||||
|
indices: [
|
||||||
|
[0, 0]
|
||||||
|
],
|
||||||
|
matches: [
|
||||||
|
{
|
||||||
|
value: s.title,
|
||||||
|
key: 'title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
arrayIndex: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
} else {
|
||||||
|
const fuse = new Fuse(series, fuseOptions);
|
||||||
|
suggestions = fuse.search(value);
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({ suggestions });
|
this.setState({ suggestions });
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ function createCleanSeriesSelector() {
|
|||||||
sortTitle,
|
sortTitle,
|
||||||
images,
|
images,
|
||||||
alternateTitles,
|
alternateTitles,
|
||||||
|
firstCharacter: title.charAt(0).toLowerCase(),
|
||||||
tags: tags.map((id) => {
|
tags: tags.map((id) => {
|
||||||
return allTags.find((tag) => tag.id === id);
|
return allTags.find((tag) => tag.id === id);
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user