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
cpradio 59922a7899 Extract autocomplete initialization to a function
Create a REGEXP_TAGS_REPLACE regex to remove a chained .replace call

Fix autocomplete positioning
2017-02-27 07:48:14 -05:00

24 lines
769 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({
@computed('searchService.searchContextEnabled')
placeholder(searchContextEnabled) {
return searchContextEnabled ? "" : I18n.t('search.title');
},
@on("didInsertElement")
becomeFocused() {
const $searchInput = this.$();
applySearchAutocomplete($searchInput, this.siteSettings);
if (!this.get('hasAutofocus')) { return; }
// iOS is crazy, without this we will not be
// at the top of the page
$(window).scrollTop(0);
$searchInput.focus();
}
});