[Autocomplete] support pagination on Asynchronous requests

See original GitHub issue

Would be very nice to add any ability for support pagination on Asynchronous requests Many resources have limitations on requests and we can not get all results at once Also reading everything page by page can lead to exceed limit of requests and it will be too slow

We would likely need to extend the API:

diff --git a/packages/material-ui/src/Autocomplete/Autocomplete.d.ts b/packages/material-ui/src/Autocomplete/Autocomplete.d.ts
index a2929c4867..39fa7130b3 100644
--- a/packages/material-ui/src/Autocomplete/Autocomplete.d.ts
+++ b/packages/material-ui/src/Autocomplete/Autocomplete.d.ts
@@ -143,6 +143,11 @@ export interface AutocompleteProps<
    * @default false
    */
   loading?: boolean;
+  /**
+   * If `true`, the `loadingMoreText` message is displayed at the bottom of the displayed options.
+   * @default false
+   */
+   loadingMore?: boolean;
   /**
    * Text to display when in a loading state.
    *
@@ -150,6 +155,13 @@ export interface AutocompleteProps<
    * @default 'Loading…'
    */
   loadingText?: React.ReactNode;
+  /**
+   * Text to display when in a loading more state.
+   *
+   * For localization purposes, you can use the provided [translations](/guides/localization/).
+   * @default 'Loading more…'
+   */
+  loadingMoreText?: React.ReactNode;
   /**
    * The maximum number of tags that will be visible when not focused.
    * Set `-1` to disable the limit.
Capture d’écran 2021-07-24 à 19 24 53

Benchmark

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:71
  • Comments:31 (13 by maintainers)

github_iconTop GitHub Comments

59reactions
oliviertassinaricommented, Apr 11, 2021

So, if you provide a custom ListboxComponent component or you can detect the scroll-bottom with:

<Autocomplete
  ListboxProps={{
    onScroll: (event: React.SyntheticEvent) => {
      const listboxNode = event.currentTarget;
      if (listboxNode.scrollTop + listboxNode.clientHeight === listboxNode.scrollHeight) {
        loadMoreResults()
      }
    }
  }}
/>
21reactions
oliviertassinaricommented, Nov 19, 2019

@vadimka123 I’m not sure to understand the use case. From my perspective, pagination should not be necessary. Either you request the data incrementally and add them to the list of options, then once the list is fully loaded, you enable the search. Or you really have too much data and you opt for an instant search like call API, for each keystroke. What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Autocomplete] support pagination on Asynchronous requests
Hello! How can I do that after all? So, the Autocomplete component supports pagination on async requests? Thank you!
Read more >
React Autocomplete component - Material UI - MUI
The component supports two different asynchronous use-cases: Load on open: it waits for the component to be interacted with to load the options....
Read more >
react-select-async-paginate - npm
Collected additional data e.g. current page number etc. For first load it is additional from props, for next is additional from previous ...
Read more >
react-window-infinite-loader material-ui autocomplete
I am trying to show an infinite scrolled list inside a material-ui Autocomplete dropdown list, using react-window-infinite-loader.
Read more >
Implementing react-select Async with React Hooks and ...
This tutorial is about implementing the React Component react-select with Async AJAX request and pagination applied.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found