This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/search-text-field.js.es6
Sam Saffron 077dcc0642 FEATURE: add autocomplete discourse on full page search
This teaches chrome not to try autocompleting it.
2019-05-31 10:27:44 +10:00

28 lines
812 B
JavaScript

import computed from "ember-addons/ember-computed-decorators";
import { on } from "ember-addons/ember-computed-decorators";
import TextField from "discourse/components/text-field";
import { applySearchAutocomplete } from "discourse/lib/search";
export default TextField.extend({
autocomplete: "discourse",
@computed("searchService.searchContextEnabled")
placeholder(searchContextEnabled) {
return searchContextEnabled ? "" : I18n.t("search.full_page_title");
},
@on("didInsertElement")
becomeFocused() {
const $searchInput = this.$();
applySearchAutocomplete($searchInput, this.siteSettings);
if (!this.hasAutofocus) {
return;
}
// iOS is crazy, without this we will not be
// at the top of the page
$(window).scrollTop(0);
$searchInput.focus();
}
});