Skip to content

fix infinite loading issue in Search Dialog #632

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LooseLi
Copy link

@LooseLi LooseLi commented May 7, 2025

Description

Fixes #593

When using the search functionality in react-notion-x, we identified a user experience issue: sometimes the loading icon continues to spin indefinitely when users enter content in the search dialog, even after the search request has successfully returned.

Solution

We resolved the infinite loading issue in the search dialog with the following improvements:

  1. replace throttle with debounce:
  • switched from throttle to debounce, which is more suitable for search scenarios
  • added the {trailing: true} option to ensure that a search is always executed after the user stops typing
  • this prevents multiple searches from being triggered when users type quickly, improving performance
  1. optimize query state management:
  • store the current query for later comparison
  • only update the UI state when the current query matches the query in the component state
  • prevent old search results from overwriting newer ones, solving state synchronization issues
  1. improve error handling:
  • add try-catch blocks to capture errors that may occur during the search process

Notion Test Page ID

I directly provided the searchNotion function in /NotionPage.tsx to NotionRenderer, enabling the search component to display and fixing related issues.

Copy link

vercel bot commented May 7, 2025

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

Name Status Preview Updated (UTC)
react-notion-x ❌ Failed (Inspect) May 7, 2025 9:44am
react-notion-x-minimal-demo ❌ Failed (Inspect) May 7, 2025 9:44am

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.

Search dialog could spin infinitely
1 participant