Skip to content

fix infinite loading issue in Search Dialog - #632

Open
LooseLi wants to merge 1 commit into
NotionX:masterfrom
LooseLi:fix-search-dialog
Open

LooseLi wants to merge 1 commit into
NotionX:masterfrom
LooseLi:fix-search-dialog

Conversation

@LooseLi

@LooseLi LooseLi commented May 7, 2025 •

Copy link
Copy Markdown
Contributor

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.

@vercel

vercel Bot commented May 7, 2025 •

Copy link
Copy Markdown

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

This branch had an error being deployed

2 failed deployments
Preview – react-notion-x — 8b4886d2 Deployed May 7, 2025 by vercel[bot]
Preview – react-notion-x-minimal-demo — 8b4886d2 Deployed May 7, 2025 by vercel[bot]
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