NotionX / NotionX/react-notion-x

Search dialog could spin infinitely

Open
#593 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.4k
Forks
645
PR merge metrics
No merged PRs in 30d

Description

Description

In packages/react-notion-x/src/components/search-dialog.tsx, It throttles the actual search frequency to 1 request / per second. but the _onChangeQuery will always set isLoading state to false every time the input value changed, which may result in a spinning state infinitely.

Suggested fix

Replace throttle with debounce, and add the {trailing: true} option.

import debounce from 'lodash.debounce'

export class SearchDialog extends React.Component {
  componentDidMount() {
    this._search = debounce(this._searchImpl.bind(this), 1000, {trailing: true})
    this._warmupSearch()
  }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/react-notion-x/src/components/search-dialog.tsx and trace how _onChangeQuery, _search, and isLoading interact while the query changes. Verify the search scheduling and loading state behavior, then confirm that repeated input no longer leaves the dialog spinning indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.