mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 09:22:47 +08:00
FIX: Scroll position is tracked on search page
This commit is contained in:
parent
80daa7006c
commit
7213e02dee
|
@ -0,0 +1,41 @@
|
||||||
|
import Scrolling from 'discourse/mixins/scrolling';
|
||||||
|
|
||||||
|
export default Ember.Component.extend(Scrolling, {
|
||||||
|
|
||||||
|
didReceiveAttrs() {
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
this.set('trackerName', `scroll-tracker-${this.get('name')}`);
|
||||||
|
},
|
||||||
|
|
||||||
|
didInsertElement() {
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
this.bindScrolling({ name: this.get('name') });
|
||||||
|
},
|
||||||
|
|
||||||
|
didRender() {
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
const data = this.session.get(this.get('trackerName'));
|
||||||
|
if (data && data.position >= 0 && data.tag === this.get('tag')) {
|
||||||
|
Ember.run.next(() => $(window).scrollTop(data.position + 1));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
willDestroyElement() {
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
this.unbindScrolling(this.get('name'));
|
||||||
|
},
|
||||||
|
|
||||||
|
scrolled() {
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
this.session.set(this.get('trackerName'), {
|
||||||
|
position: $(window).scrollTop(),
|
||||||
|
tag: this.get('tag'),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
|
@ -1,4 +1,5 @@
|
||||||
{{#d-section pageClass="search" class="search-container"}}
|
{{#d-section pageClass="search" class="search-container"}}
|
||||||
|
{{scroll-tracker name="full-page-search" tag=searchTerm}}
|
||||||
<div class="search row clearfix">
|
<div class="search row clearfix">
|
||||||
{{search-text-field value=searchTerm class="full-page-search input-xxlarge search no-blur" action="search" hasAutofocus=hasAutofocus}}
|
{{search-text-field value=searchTerm class="full-page-search input-xxlarge search no-blur" action="search" hasAutofocus=hasAutofocus}}
|
||||||
{{d-button action="search" icon="search" class="btn-primary" disabled=searching}}
|
{{d-button action="search" icon="search" class="btn-primary" disabled=searching}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user