mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 22:26:26 +08:00
FIX: Limit number of items for category hashtag autocomplete.
This commit is contained in:
parent
73336db311
commit
3af7509945
|
@ -258,10 +258,23 @@ export default Ember.Component.extend({
|
|||
return category.get('slug');
|
||||
},
|
||||
dataSource(term) {
|
||||
return Category.list().filter(category => {
|
||||
const regexp = new RegExp(term, 'i');
|
||||
return category.get('name').match(regexp);
|
||||
const limit = 5;
|
||||
const regexp = new RegExp(term, 'i');
|
||||
var count = 0;
|
||||
var data = [];
|
||||
|
||||
Category.listByActivity().some(category => {
|
||||
console.log(category);
|
||||
|
||||
if (category.get('name').match(regexp)) {
|
||||
count++;
|
||||
data.push(category);
|
||||
}
|
||||
|
||||
return count === limit;
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
triggerRule(textarea, opts) {
|
||||
const result = Discourse.Utilities.caretRowCol(textarea);
|
||||
|
|
Loading…
Reference in New Issue
Block a user