From a626062931a3c2c9d0f8adfdde2bf6996bc57094 Mon Sep 17 00:00:00 2001 From: sjhuang26 <sjhuang26@gmail.com> Date: Tue, 29 May 2018 16:03:34 -0400 Subject: [PATCH] Additional fixes --- src/components/library/library.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/library/library.jsx b/src/components/library/library.jsx index 0a3e3b525..c58d3608c 100644 --- a/src/components/library/library.jsx +++ b/src/components/library/library.jsx @@ -43,6 +43,12 @@ class LibraryComponent extends React.Component { selectedTag: ALL_TAG_TITLE.toLowerCase() }; } + componentDidUpdate (prevProps, prevState) { + if (prevState.filterQuery !== this.state.filterQuery || + prevState.selectedTag !== this.state.selectedTag) { + this.scrollToTop(); + } + } handleBlur (id) { this.handleMouseLeave(id); } @@ -58,7 +64,6 @@ class LibraryComponent extends React.Component { filterQuery: '', selectedTag: tag.toLowerCase() }); - this.scrollToTop(); } handleMouseEnter (id) { if (this.props.onItemMouseEnter) this.props.onItemMouseEnter(this.getFilteredData()[id]); @@ -71,7 +76,6 @@ class LibraryComponent extends React.Component { filterQuery: event.target.value, selectedTag: ALL_TAG_TITLE.toLowerCase() }); - this.scrollToTop(); } handleFilterClear () { this.setState({filterQuery: ''}); -- GitLab