mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 12:13:37 +08:00
FIX: Search menu results does not refresh when search context is changed.
This commit is contained in:
parent
758e3e52f7
commit
ac37bd3dbc
|
@ -206,6 +206,7 @@ export default createWidget('header', {
|
|||
state.contextEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
panels.push(this.attach('search-menu', { contextEnabled: state.contextEnabled }));
|
||||
} else if (state.hamburgerVisible) {
|
||||
panels.push(this.attach('hamburger-menu'));
|
||||
|
@ -303,6 +304,7 @@ export default createWidget('header', {
|
|||
},
|
||||
|
||||
searchMenuContextChanged(value) {
|
||||
this.state.contextType = this.register.lookup('search-service:main').get('contextType');
|
||||
this.state.contextEnabled = value;
|
||||
},
|
||||
|
||||
|
|
|
@ -148,7 +148,12 @@ export default createWidget('search-menu', {
|
|||
},
|
||||
|
||||
html(attrs) {
|
||||
searchData.contextEnabled = attrs.contextEnabled;
|
||||
if (searchData.contextEnabled !== attrs.contextEnabled) {
|
||||
searchData.contextEnabled = attrs.contextEnabled;
|
||||
this.triggerSearch();
|
||||
} else {
|
||||
searchData.contextEnabled = attrs.contextEnabled;
|
||||
}
|
||||
|
||||
return this.attach('menu-panel', { maxWidth: 500, contents: () => this.panelContents() });
|
||||
},
|
||||
|
|
|
@ -47,3 +47,29 @@ test("search scope checkbox", () => {
|
|||
});
|
||||
});
|
||||
|
||||
test("Search with context", assert => {
|
||||
visit("/t/internationalization-localization/280/1");
|
||||
|
||||
click('#search-button');
|
||||
fillIn('#search-term', 'dev');
|
||||
click(".search-context input[type='checkbox']");
|
||||
keyEvent('#search-term', 'keyup', 16);
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.search-menu .results ul li'), 'it shows results');
|
||||
});
|
||||
|
||||
visit("/");
|
||||
click('#search-button');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists(".search-context input[type='checkbox']"));
|
||||
});
|
||||
|
||||
visit("/t/internationalization-localization/280/1");
|
||||
click('#search-button');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!$('.search-context input[type=checkbox]').is(":checked"));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user