allenai / pdf-component-library

44 stars 4 forks source link

Fix Scroll issue due to the new layout creation for Semantic Reader #133

Closed huytr1995 closed 2 years ago

huytr1995 commented 2 years ago

Description

Ref: https://github.com/allenai/scholar/issues/32270

With the new reader layout now using the outer scroll instead of the inner one which will render our scroll.ts to be useless. Its originally was targeting reader__page-list but now the scroll is on react-pdf__Document reader__main

Reviewer Instructions

My thought originally was tagging all the page with a ref which is the way that Yensung did too. So i tagged every page in the list with the ref and save the ref in the DocumentContext and pass that ref into the scroll.ts, instead of directly creating the target div, i use parentNode property of the ref and execute scroll directly on that parent since every page only has one relative parent that is react-pdf__Document reader__main

Testing Plan

Manually test by clicking all the option of TOC and expect them to be able to scroll to the correct position. Other than that lint and format.

Output / Screenshots

https://user-images.githubusercontent.com/84343285/175996038-9272c210-75d0-43f0-8fb8-022e72036a33.mov

A11y

No A11y involvement in this