Skip to content

Search dialog could spin infinitely #593

Open
@sagan

Description

@sagan

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()
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions