FIX: Category autocomplete breaks when search menu widget rerenders.
https://github.com/discourse/discourse/pull/4717#issuecomment-284914585
This commit is contained in:
parent
3c41cb6b7d
commit
6a7773b681
|
@ -261,7 +261,11 @@ export default function(options) {
|
|||
left: "-1000px"
|
||||
});
|
||||
|
||||
me.parent().append(div);
|
||||
if (options.appendSelector) {
|
||||
me.parents(options.appendSelector).append(div);
|
||||
} else {
|
||||
me.parent().append(div);
|
||||
}
|
||||
|
||||
if (!isInput && !options.treatAsTextarea) {
|
||||
vOffset = div.height();
|
||||
|
|
|
@ -130,14 +130,14 @@ export function isValidSearchTerm(searchTerm) {
|
|||
}
|
||||
};
|
||||
|
||||
export function applySearchAutocomplete($input, siteSettings, appEvents) {
|
||||
export function applySearchAutocomplete($input, siteSettings, appEvents, options) {
|
||||
const afterComplete = function() {
|
||||
if (appEvents) {
|
||||
appEvents.trigger("search-autocomplete:after-complete");
|
||||
}
|
||||
};
|
||||
|
||||
$input.autocomplete({
|
||||
$input.autocomplete(_.merge({
|
||||
template: findRawTemplate('category-tag-autocomplete'),
|
||||
key: '#',
|
||||
width: '100%',
|
||||
|
@ -153,9 +153,9 @@ export function applySearchAutocomplete($input, siteSettings, appEvents) {
|
|||
return searchCategoryTag(term, siteSettings);
|
||||
},
|
||||
afterComplete
|
||||
});
|
||||
}, options));
|
||||
|
||||
$input.autocomplete({
|
||||
$input.autocomplete(_.merge({
|
||||
template: findRawTemplate('user-selector-autocomplete'),
|
||||
key: "@",
|
||||
width: '100%',
|
||||
|
@ -163,5 +163,5 @@ export function applySearchAutocomplete($input, siteSettings, appEvents) {
|
|||
transformComplete: v => v.username || v.name,
|
||||
dataSource: term => userSearch({ term, includeGroups: true }),
|
||||
afterComplete
|
||||
});
|
||||
}, options));
|
||||
};
|
||||
|
|
|
@ -262,7 +262,10 @@ export default createWidget('header', {
|
|||
Ember.run.schedule('afterRender', () => {
|
||||
const $searchInput = $('#search-term');
|
||||
$searchInput.focus().select();
|
||||
applySearchAutocomplete($searchInput, this.siteSettings, this.appEvents);
|
||||
|
||||
applySearchAutocomplete($searchInput, this.siteSettings, this.appEvents, {
|
||||
appendSelector: '.menu-panel'
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue