Fix post edit form closed on nav cancel
This commit is contained in:
parent
61255bf01a
commit
66090326a2
1 changed files with 11 additions and 7 deletions
|
@ -219,6 +219,7 @@ const LinkButton = ({
|
||||||
|
|
||||||
export class Home extends Component<any, HomeState> {
|
export class Home extends Component<any, HomeState> {
|
||||||
private isoData = setIsoData<HomeData>(this.context);
|
private isoData = setIsoData<HomeData>(this.context);
|
||||||
|
private unregisterHistoryListener: () => void;
|
||||||
state: HomeState = {
|
state: HomeState = {
|
||||||
postsRes: { state: "empty" },
|
postsRes: { state: "empty" },
|
||||||
commentsRes: { state: "empty" },
|
commentsRes: { state: "empty" },
|
||||||
|
@ -291,6 +292,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
this.unregisterHistoryListener();
|
||||||
HomeCacheService.activate();
|
HomeCacheService.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,6 +306,15 @@ export class Home extends Component<any, HomeState> {
|
||||||
await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
|
await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.unregisterHistoryListener = this.props.history.listen(() => {
|
||||||
|
if (!this.state.scrolled) {
|
||||||
|
this.setState({ scrolled: true });
|
||||||
|
setTimeout(() => window.scrollTo(0, 0), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fetchData();
|
||||||
|
});
|
||||||
|
|
||||||
setupTippy();
|
setupTippy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,13 +645,6 @@ export class Home extends Component<any, HomeState> {
|
||||||
pathname: "/",
|
pathname: "/",
|
||||||
search: getQueryString(queryParams),
|
search: getQueryString(queryParams),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!this.state.scrolled) {
|
|
||||||
this.setState({ scrolled: true });
|
|
||||||
setTimeout(() => window.scrollTo(0, 0), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.fetchData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get posts() {
|
get posts() {
|
||||||
|
|
Loading…
Reference in a new issue