mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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"
|
left: "-1000px"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (options.appendSelector) {
|
||||||
|
me.parents(options.appendSelector).append(div);
|
||||||
|
} else {
|
||||||
me.parent().append(div);
|
me.parent().append(div);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isInput && !options.treatAsTextarea) {
|
if (!isInput && !options.treatAsTextarea) {
|
||||||
vOffset = div.height();
|
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() {
|
const afterComplete = function() {
|
||||||
if (appEvents) {
|
if (appEvents) {
|
||||||
appEvents.trigger("search-autocomplete:after-complete");
|
appEvents.trigger("search-autocomplete:after-complete");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$input.autocomplete({
|
$input.autocomplete(_.merge({
|
||||||
template: findRawTemplate('category-tag-autocomplete'),
|
template: findRawTemplate('category-tag-autocomplete'),
|
||||||
key: '#',
|
key: '#',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@ -153,9 +153,9 @@ export function applySearchAutocomplete($input, siteSettings, appEvents) {
|
|||||||
return searchCategoryTag(term, siteSettings);
|
return searchCategoryTag(term, siteSettings);
|
||||||
},
|
},
|
||||||
afterComplete
|
afterComplete
|
||||||
});
|
}, options));
|
||||||
|
|
||||||
$input.autocomplete({
|
$input.autocomplete(_.merge({
|
||||||
template: findRawTemplate('user-selector-autocomplete'),
|
template: findRawTemplate('user-selector-autocomplete'),
|
||||||
key: "@",
|
key: "@",
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@ -163,5 +163,5 @@ export function applySearchAutocomplete($input, siteSettings, appEvents) {
|
|||||||
transformComplete: v => v.username || v.name,
|
transformComplete: v => v.username || v.name,
|
||||||
dataSource: term => userSearch({ term, includeGroups: true }),
|
dataSource: term => userSearch({ term, includeGroups: true }),
|
||||||
afterComplete
|
afterComplete
|
||||||
});
|
}, options));
|
||||||
};
|
};
|
||||||
|
@ -262,7 +262,10 @@ export default createWidget('header', {
|
|||||||
Ember.run.schedule('afterRender', () => {
|
Ember.run.schedule('afterRender', () => {
|
||||||
const $searchInput = $('#search-term');
|
const $searchInput = $('#search-term');
|
||||||
$searchInput.focus().select();
|
$searchInput.focus().select();
|
||||||
applySearchAutocomplete($searchInput, this.siteSettings, this.appEvents);
|
|
||||||
|
applySearchAutocomplete($searchInput, this.siteSettings, this.appEvents, {
|
||||||
|
appendSelector: '.menu-panel'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user