Skip to content

Conversation

@limaagabriel
Copy link
Member

Ticket: https://liferay.atlassian.net/browse/LPD-55597

This update adds the useInfiniteScrolling hook to the Autocomplete component. This hook implements several specific improvements that are best grouped. Additionally, it deviates slightly from the generic Collection behavior.

It works by decorating the onLoadMore prop. Whenever it is provided, this hook understands that infinite scrolling is enabled. Therefore, it decorates the function to let the effects work by adding three main features:

  1. Screen reader announcements
  2. Load more triggers by scrolling to the bottom of the list
  3. Load more triggers by focusing on the last item of the list

This hook uses more refs to avoid adding re-renders to the component itself. These refs store data to allow the effects to be more controlled.

@vercel
Copy link

vercel bot commented Nov 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clayui.com Ready Ready Preview Comment Dec 5, 2025 5:30pm
storybook.clayui.com Ready Ready Preview Comment Dec 5, 2025 5:30pm

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds infinite scrolling capabilities to the @clayui/autocomplete component with accessibility improvements including screen reader announcements and visual feedback. The implementation introduces a new useInfiniteScrolling hook that decorates the onLoadMore prop to enable three key features: SR announcements, scroll-triggered loading, and focus-triggered loading when reaching the last item.

Key Changes:

  • Introduced useInfiniteScrolling hook with accessibility-focused infinite scrolling implementation
  • Extended AutocompleteMessages type to support new infinite scrolling announcement messages
  • Added batchLoadCount prop to specify the number of items loaded per batch
  • Created story examples demonstrating infinite scrolling with various data sources

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.

File Description
packages/clay-autocomplete/src/useInfiniteScrolling.tsx New hook implementing infinite scrolling with SR announcements, IntersectionObserver-based loading trigger, and scroll position management
packages/clay-autocomplete/src/Autocomplete.tsx Integrated useInfiniteScrolling hook, extended message type definitions, and added infinite scrolling trigger component to dropdown menu
packages/clay-autocomplete/stories/Autocomplete.stories.tsx Added InfiniteScrolling story demonstrating the feature with Rick and Morty API and generated number lists

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@limaagabriel limaagabriel marked this pull request as ready for review December 2, 2025 15:46
…em using the autocomplete focuses on the last item, but doesn't scroll to it
…focusing the last item, letting the scroll handle this case as well
…s where the list is short and scrolling isn't available, by proactively checking if it is at the trigger zone
…ndicate the intention of some keyboard bindings
…he autocomplete, so it is possible to import NetworkStatus
Copy link
Member

@ethib137 ethib137 left a comment

Choose a reason for hiding this comment

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

LGTM... thanks... Can you also create another subtask for applying this to Portal by adding the new language keys to the usages where infinite scroll is taking place. I don't think we have one for that yet, right?

@ethib137 ethib137 merged commit 02e70f6 into liferay:master Dec 11, 2025
5 checks passed
@limaagabriel limaagabriel deleted the LPD-55597 branch December 11, 2025 11:21
@limaagabriel
Copy link
Member Author

@ethib137 Yeah, I don't think we have this ticket yet. I'll create it right away.

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.

3 participants