allenai / pdf-component-library

44 stars 4 forks source link

Avoid Header Collapses when user clicks on TOC Part1 #176

Closed huytr1995 closed 2 years ago

huytr1995 commented 2 years ago

Description

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

On Bug Bash we noticed that when we click on any section of TOC. It will scroll to the position and at the same time collapse header which is not desirable. This PR addresses this issue.

Reviewer Instructions

I created a useState called IsOutlineGetClicked and when it get clicked this will set to true (this happens inside ScrollContext since when we click on Outline it will call scrollToOutlineTarget in ScrollContext). But on user mouse wheel in general it will set to false so the header will collapse like normal (scroll doesn't work since it not count toward user actually scroll).

Testing Plan

To verify it works in Prod. In ReaderHeader i specifically add code like below to verify it works. Other than that yarn format, lint, test.

ReaderHeader image Reader image

Output / Screenshots

https://user-images.githubusercontent.com/84343285/186518383-3c441b23-33a1-44ad-b205-32c5b887a9e0.mov

A11y

No A11y involvement