mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 20:52:46 +08:00
FIX: Don't close search menu on link clicked when context is enabled.
This commit is contained in:
parent
de6ca4f736
commit
ee58c4cd94
|
@ -225,8 +225,8 @@ export default createWidget('header', {
|
|||
this.state.searchVisible = false;
|
||||
},
|
||||
|
||||
linkClickedEvent() {
|
||||
this.closeAll();
|
||||
linkClickedEvent(attrs) {
|
||||
if (!attrs.searchContextEnabled) this.closeAll();
|
||||
this.updateHighlight();
|
||||
},
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ export default createWidget('link', {
|
|||
e.preventDefault();
|
||||
return this.sendWidgetAction(this.attrs.action, this.attrs.actionParam);
|
||||
} else {
|
||||
this.sendWidgetEvent('linkClicked');
|
||||
this.sendWidgetEvent('linkClicked', this.attrs);
|
||||
}
|
||||
|
||||
return DiscourseURL.routeToTag($(e.target).closest('a')[0]);
|
||||
|
|
|
@ -25,7 +25,8 @@ function createSearchResult(type, linkField, fn) {
|
|||
return h('li', this.attach('link', {
|
||||
href: r.get(linkField),
|
||||
contents: () => fn.call(this, r, attrs.term),
|
||||
className: 'search-link'
|
||||
className: 'search-link',
|
||||
searchContextEnabled: this.attrs.searchContextEnabled
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
@ -98,7 +99,11 @@ createWidget('search-menu-results', {
|
|||
}
|
||||
|
||||
return [
|
||||
h('ul', this.attach(rt.componentName, { results: rt.results, term: attrs.term })),
|
||||
h('ul', this.attach(rt.componentName, {
|
||||
searchContextEnabled: this.attrs.searchContextEnabled,
|
||||
results: rt.results,
|
||||
term: attrs.term
|
||||
})),
|
||||
h('div.no-results', more)
|
||||
];
|
||||
});
|
||||
|
|
|
@ -125,7 +125,8 @@ export default createWidget('search-menu', {
|
|||
results.push(this.attach('search-menu-results', { term: searchData.term,
|
||||
noResults: searchData.noResults,
|
||||
results: searchData.results,
|
||||
invalidTerm: searchData.invalidTerm }));
|
||||
invalidTerm: searchData.invalidTerm,
|
||||
searchContextEnabled: searchData.contextEnabled }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -298,12 +298,12 @@ export default class Widget {
|
|||
return result;
|
||||
}
|
||||
|
||||
sendWidgetEvent(name) {
|
||||
sendWidgetEvent(name, attrs) {
|
||||
const methodName = `${name}Event`;
|
||||
return this.rerenderResult(() => {
|
||||
const widget = this._findAncestorWithProperty(methodName);
|
||||
if (widget) {
|
||||
return widget[methodName]();
|
||||
return widget[methodName](attrs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user