Skip to content

[CLNP-6463][fix]: fix scroll pagination failing after offline or search query change #1416

Open
sf-tyler-jeong wants to merge 4 commits intomainfrom
bug-fix/CLNP-6463
Open

[CLNP-6463][fix]: fix scroll pagination failing after offline or search query change #1416
sf-tyler-jeong wants to merge 4 commits intomainfrom
bug-fix/CLNP-6463

Conversation

@sf-tyler-jeong
Copy link
Copy Markdown

@sf-tyler-jeong sf-tyler-jeong commented Apr 6, 2026

Fix MessageSearch scroll pagination that breaks after going offline or changing the search query.

Root cause:

  • useScrollCallback captured a stale currentMessageSearchQuery in its useCallback closure
  • When the query object changed (after reconnect or new search), the callback still referenced the old query
  • hasMoreResult state could become stale, blocking further pagination

Changes (useScrollCallback.ts):

  • Use useRef to always access the latest currentMessageSearchQuery without re-creating the callback
  • Add offline check (navigator.onLine) to skip loading when disconnected
  • Add isLoading guard to prevent duplicate concurrent requests
  • Remove dependency on hasMoreResult state; use query.hasNext directly from the live query object
  • Stabilize useCallback with empty dependency array since all state is accessed via ref

Test changes (useScrollCallback.spec.ts):

  • Updated existing test cases to match new warning messages and removed hasMoreResult references
  • Added test: should log warning when offline (navigator.onLine = false)
  • Added test: should log warning when query is already loading (isLoading: true)
  • Added test: should use latest query via ref when callback is called (verifies stale closure fix)
  • Added isLoading field to all mock query objects
  • Wrapped async test operations in act() for React state update compatibility

Fixes CLNP-6463

Changelogs

  • Fixed a bug where MessageSearch scroll pagination stopped working after going offline or changing the search query
  • Added offline detection to prevent unnecessary search requests when disconnected
  • Added loading guard to prevent duplicate concurrent pagination requests

Checklist

  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • Public components / utils / props are appropriately exported
  • I have added necessary documentation (if appropriate)

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 6, 2026

Deploy Preview for sendbird-uikit-react ready!

Name Link
🔨 Latest commit 2ef39e3
🔍 Latest deploy log https://app.netlify.com/projects/sendbird-uikit-react/deploys/69d357599181740008edaa51
😎 Deploy Preview https://deploy-preview-1416--sendbird-uikit-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcb1638cf7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/modules/MessageSearch/context/hooks/useScrollCallback.ts
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