diff --git a/src/components/GalleryViewThumbnail.js b/src/components/GalleryViewThumbnail.js index 80ae8e1277e13296f66c1a2e379b00c736000ef3..acfe18aae196a5a4e489918c88a556042274800f 100644 --- a/src/components/GalleryViewThumbnail.js +++ b/src/components/GalleryViewThumbnail.js @@ -19,6 +19,7 @@ export class GalleryViewThumbnail extends Component { constructor(props) { super(props); + this.myRef = React.createRef(); this.state = { requestedAnnotations: false }; this.handleSelect = this.handleSelect.bind(this); @@ -26,6 +27,14 @@ export class GalleryViewThumbnail extends Component { this.handleIntersection = this.handleIntersection.bind(this); } + // eslint-disable-next-line require-jsdoc + componentDidMount() { + const { selected } = this.props; + if (selected) { + this.myRef.current?.scrollIntoView(true); + } + } + /** @private */ handleSelect() { const { @@ -112,6 +121,7 @@ export class GalleryViewThumbnail extends Component { } onClick={this.handleSelect} onKeyUp={this.handleKey} + ref={this.myRef} role="button" tabIndex={0} >