Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Search dialog could spin infinitely #593

Open
sagan opened this issue Nov 28, 2024 · 0 comments
Open

Search dialog could spin infinitely #593

sagan opened this issue Nov 28, 2024 · 0 comments

Comments

@sagan
Copy link

sagan commented Nov 28, 2024

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()
  }
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant