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: improve useInViewObserver hook to trigger when observer is in view on mount #18446

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

cnhhoang850
Copy link
Contributor

@cnhhoang850 cnhhoang850 commented Jan 2, 2025

What does this PR do?

This pull request makes inViewObserver trigger when ref element already intersect view port on mount.

Currently, inViewObserver triggers only when ref element "enters" view port after component mount. This makes infinite scroll loading behavior doesn't work on first page load if view port contains inViewObserver ref element

This PR makes inViewObserver always trigger when ref element is in view, even on first mount, making its behavior more consistent.

As a consequence, any infinite scrolling list that use inViewObserver will continue to load element on first mount up until the point ref element doesn't intersect the view port any more.

Before

Personal.Event.Types.Cal.com.-.2.January.2025.mp4

After

https___www.loom.com_share_60b418ebda554e90a711a6ed0be295f4.-.New.mp4

Loom Video: https://www.loom.com/share/60b418ebda554e90a711a6ed0be295f4?sid=4e41bb73-9501-4f0f-8df2-e0d2953c64c4

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Visit any infinite loading list that uses inViewObserver
  • List should loads data until inViewObserver ref element is below view port
  • Scroll to inViewObserver ref element should trigger callback

@CLAassistant
Copy link

CLAassistant commented Jan 2, 2025

CLA assistant check
All committers have signed the CLA.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Jan 2, 2025
@graphite-app graphite-app bot requested a review from a team January 2, 2025 15:49
Copy link

vercel bot commented Jan 2, 2025

@cnhhoang850 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the 🐛 bug Something isn't working label Jan 2, 2025
Copy link

graphite-app bot commented Jan 2, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (01/02/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (01/02/25)

1 label was added to this PR based on Keith Williams's automation.

"Add ready-for-e2e label" took an action on this PR • (01/02/25)

1 label was added to this PR based on Keith Williams's automation.

@emrysal emrysal enabled auto-merge (squash) January 2, 2025 23:40
Copy link
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

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

Like this a lot!

@emrysal emrysal merged commit 22f92f1 into calcom:main Jan 2, 2025
58 of 83 checks passed
Copy link
Contributor

github-actions bot commented Jan 3, 2025

E2E results are ready!

@cnhhoang850 cnhhoang850 deleted the fix/use-in-view-observer branch January 3, 2025 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working community Created by Linear-GitHub Sync ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants