Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mismatch with ToC #516

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

IshavSohal
Copy link
Member

@IshavSohal IshavSohal commented Dec 9, 2024

Related Item(s)

ramp4-pcar4/storylines-editor#437

Changes

  • Set top position for the scroll behavior of slides such that the slides corresponding ToC icon is highlighted (rather than the subsequent icon)

Testing

Steps:

  1. Open a product with a vertical ToC
  2. Scroll through the slides, and ensure that the correct ToC icon is highlighted
  3. Click on the ToC icons and ensure that they are highlighted (rather than the subsequent icon)
  4. Decrease the screen width and repeat steps 2-3

This change is Reviewable

@IshavSohal IshavSohal added the PR: Frontend PR that primarily involves frontend changes. UI experts and CSS Wizards are asked to review. label Dec 9, 2024
Copy link

github-actions bot commented Dec 9, 2024

Copy link
Member

@RyanCoulsonCA RyanCoulsonCA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @IshavSohal)


src/router/index.ts line 28 at r1 (raw file):

                el: decodeURIComponent(to.hash),
                behavior: 'smooth',
                top: window.innerHeight / 6

This seems to fix the issue, but I'm wondering if there's maybe a way to fix this problem by adjusting the activeChapterIndex logic instead? There are some fancy calculations being done here, which is what we use to determine which chapter is currently active (and therefore which ToC entry is highlighted). Maybe playing around with this logic may also fix the problem?

EDIT: The scrollama component in the same file also supports a threshold property that may be useful to play around with as well.

The previous top value calculation was just added about a month ago to fix an issue where clicking on a ToC entry wouldn't take the user to the top of a slide, which this new calculation re-introduces.

Copy link
Member Author

@IshavSohal IshavSohal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @RyanCoulsonCA)


src/router/index.ts line 28 at r1 (raw file):

Previously, RyanCoulsonCA (Ryan Coulson) wrote…

This seems to fix the issue, but I'm wondering if there's maybe a way to fix this problem by adjusting the activeChapterIndex logic instead? There are some fancy calculations being done here, which is what we use to determine which chapter is currently active (and therefore which ToC entry is highlighted). Maybe playing around with this logic may also fix the problem?

The previous top value calculation was just added about a month ago to fix an issue where clicking on a ToC entry wouldn't take the user to the top of a slide, which this new calculation re-introduces.

Donethanks. I decided to set the offset property (which has default value of 0.5) to 0.1. This causes a slide change to be detected when the top border of a slide crosses the 10% mark of the screen.

Copy link
Member

@yileifeng yileifeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing against both the horizontal ToC (https://ramp4-pcar4.github.io/story-ramp/toc-mismatch/#/en/00000000-0000-0000-0000-000000000000) and vertical ToC (https://ramp4-pcar4.github.io/story-ramp/toc-mismatch/#/fr/00000000-0000-0000-0000-000000000000), clicking on a ToC item scrolls to the correct section but highlights the wrong item.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @RyanCoulsonCA)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Frontend PR that primarily involves frontend changes. UI experts and CSS Wizards are asked to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants