Skip to content

Commit

Permalink
update to page view scrolling implementation using the existing utils -
Browse files Browse the repository at this point in the history
  • Loading branch information
vbojilova committed Feb 21, 2024
1 parent 7679373 commit 892a0e3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/containers/PageView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import {
getMarkdownField,
} from 'utils/fields';

import { scrollToTop } from 'utils/scroll-to-component';

import messages from './messages';
import { selectViewEntity } from './selectors';
import { DEPENDENCIES } from './constants';
Expand All @@ -57,7 +59,7 @@ const ViewContainer = styled(Container)`
export class PageView extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
constructor(props) {
super(props);
this.topOfPageRef = createRef();
this.scrollContainerRef = createRef();
}

UNSAFE_componentWillMount() {
Expand All @@ -73,8 +75,8 @@ export class PageView extends React.PureComponent { // eslint-disable-line react

componentDidUpdate() {
// if component is loaded, scroll to the top of the page
if (this.topOfPageRef.current) {
this.topOfPageRef.current.scrollIntoView();
if (this.scrollContainerRef.current) {
scrollToTop(this.scrollContainerRef.current);
}
}

Expand Down Expand Up @@ -128,9 +130,8 @@ export class PageView extends React.PureComponent { // eslint-disable-line react
{ name: 'description', content: intl.formatMessage(messages.metaDescription) },
]}
/>
<Styled className={`content-${CONTENT_PAGE}`}>
<Styled className={`content-${CONTENT_PAGE}`} ref={this.scrollContainerRef}>
<ViewContainer isNarrow={!isManager}>
<span ref={this.topOfPageRef} />
<ContentHeader
title={page ? page.getIn(['attributes', 'title']) : ''}
supTitle={page ? page.getIn(['attributes', 'menu_title']) : ''}
Expand Down

0 comments on commit 892a0e3

Please sign in to comment.