Magento ui-select component filter rate limit extender customization

Magento ui-select component filter rate limit extender customization

Magento 2 ui-select component is a great instrument to search for collection of items and render them in result list. More details about ui-select component you can find here: https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-secondary-uiselect.html

Since Magento 2.3.2 version you can customize filter rateLimit extender of ui-select. By default Magento/Ui/view/base/web/js/form/element/ui-select.js component has following settings:

filterRateLimit: 500,
filterRateLimitMethod: 'notifyAtFixedRate'

It means that while typing in search input field search term every 500 milliseconds ui-select sends AJAX request to the server with search request.

The problem here is that you do not need multiple requests (‘San’, ‘San Fr’, ‘San Fran’, San Francis’) while typing for example ‘San Francisco’ term in search input field of ui-select. You need to send just 1 request after user stops typing.

Ui-select gives just ability. To send only 1 request after stop typing you need to customizeĀ  filterRateLimitMethod attribute of you ui-select component. Just set it to 'filterRateLimitMethod' => 'notifyWhenChangesStop'

More details about rateLimit here: https://knockoutjs.com/documentation/rateLimit-observable.html

Leave a Reply

Close Menu