FIX: Don't bind events in `defaultState`

This commit is contained in:
Robin Ward 2017-09-04 11:48:36 -04:00
parent afe6f46b03
commit be1cce503c
2 changed files with 7 additions and 5 deletions

View File

@ -62,6 +62,8 @@ const SiteHeaderComponent = MountWidget.extend(Docking, {
this.dispatch('notifications:changed', 'user-notifications');
this.dispatch('header:keyboard-trigger', 'header');
this.dispatch('header:keyboard-trigger', 'header');
this.dispatch('search-autocomplete:after-complete', 'search-term');
this.appEvents.on('dom:clean', () => {
// For performance, only trigger a re-render if any menu panels are visible

View File

@ -5,16 +5,16 @@ import { createWidget } from 'discourse/widgets/widget';
createWidget('search-term', {
tagName: 'input',
buildId: () => 'search-term',
buildKey: (attrs) => `search-term-${attrs.id}`,
buildKey: () => `search-term`,
defaultState() {
this.appEvents.on("search-autocomplete:after-complete", () => {
this.state.afterAutocomplete = true;
});
return { afterAutocomplete: false };
},
searchAutocompleteAfterComplete() {
this.state.afterAutocomplete = true;
},
buildAttributes(attrs) {
return { type: 'text',
value: attrs.value || '',