Skip to content

fix(PM-1448): implemented client side infinite scroll #1131

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

Merged
merged 5 commits into from
Jul 10, 2025

Conversation

hentrymartin
Copy link
Collaborator

Related JIRA Ticket:

https://topcoder.atlassian.net/browse/PM-1448

What's in this PR?

  • Implemented client side infinite scroll
  • I tried to implement virtual list but with the two column layout, its tricky to implement it so settled with infinite scroll
  • This will not improve anything on server side, the initial call is gonna take more time to load(as its going through 10000 members record to find the skills match)

@@ -17,6 +17,9 @@ import styles from './SearchResultsPage.module.scss'
const SearchResultsPage: FC = () => {
const [showSkillsModal, setShowSkillsModal] = useState(false)

const [currentPage, setCurrentPage] = useState(1)
const itemsPerPage = 10
Copy link

Choose a reason for hiding this comment

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

Consider making itemsPerPage a constant outside of the component if it does not change, to avoid re-declaring it on every render.

@@ -25,6 +28,30 @@ const SearchResultsPage: FC = () => {
hasNext,
Copy link

Choose a reason for hiding this comment

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

Typo in InfiniteTalentMatchesResposne, it should be InfiniteTalentMatchesResponse.

const visibleHeight = window.innerHeight
const fullHeight = document.body.scrollHeight

if (scrollY + visibleHeight >= fullHeight - 100) {
Copy link

Choose a reason for hiding this comment

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

Consider adding a debounce or throttle mechanism to the scroll event handler to improve performance and prevent excessive function calls during rapid scrolling.

@hentrymartin hentrymartin requested a review from kkartunov July 10, 2025 15:21
const visibleHeight = window.innerHeight
const fullHeight = document.body.scrollHeight
const footerElem = document.getElementById("footer-nav-el");
const footerHeight = footerElem && footerElem.offsetHeight || 650;

Choose a reason for hiding this comment

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

Consider using optional chaining when accessing footerElem.offsetHeight to avoid potential runtime errors if footerElem is null. For example: const footerHeight = footerElem?.offsetHeight || 650;

const fullHeight = document.body.scrollHeight
const footerElem = document.getElementById("footer-nav-el");
const footerHeight = footerElem && footerElem.offsetHeight || 650;
if (scrollY + visibleHeight >= fullHeight - footerHeight + 100) {

Choose a reason for hiding this comment

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

The condition scrollY + visibleHeight >= fullHeight - footerHeight + 100 seems to have a logic change from the original. Ensure that the + 100 adjustment is intentional and correctly accounts for the desired scroll threshold.

Copy link
Collaborator

@kkartunov kkartunov left a comment

Choose a reason for hiding this comment

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

Looks good

@hentrymartin hentrymartin merged commit 248914c into dev Jul 10, 2025
3 checks passed
@hentrymartin hentrymartin deleted the pm-1448_in-scroll branch July 10, 2025 16:05
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.

2 participants