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: settimeout trying to scroll when element is undefined #508

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arvndvv
Copy link

@arvndvv arvndvv commented Sep 10, 2024

Description

when using multiple chrono charts in single component, while its loading if we switch tab, it will result in error as shown in screenshot.

image

Additional context

This is caused by the code

setTimeout(() => { const ele = horizontalContentRef.current as HTMLElement; ele.style.scrollBehavior = 'smooth'; ele.scrollLeft += cardLeft - contentLeft + cardWidth / 2 - contentWidth / 2; }, 100);

when the settimeout of some chrono gets executed, the element might be undefined as the page might have changed.

by adding if(ele) condition to make sure the element is present before initiating the scroll, we can solve this issue.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link

vercel bot commented Sep 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-chrono-uc7v ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 15, 2025 4:32am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant