From 938f1739f737b82d8695bf70bd972c15ce5e9760 Mon Sep 17 00:00:00 2001 From: UladzislauKutarkin <72550466+UladzislauKutarkin@users.noreply.github.com> Date: Wed, 27 Sep 2023 13:11:19 +0400 Subject: [PATCH] UIPQB-51: Dropdown typeahead should use contains not starts with (#60) --- CHANGELOG.md | 1 + .../QueryBuilderModal/RepeatableFields/RepeatableFields.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c946f0c..c4b63382 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,3 +29,4 @@ * [UIPQB-50](https://issues.folio.org/browse/UIPQB-50)Add 'in-progress' handling to plugin-query-builder * [UIPQB-48](https://issues.folio.org/browse/UIPQB-48) "Show columns" dropdown doesn't fit in the screen. * [UIPQB-47](https://issues.folio.org/browse/UIPQB-47) 400 error blocks save or further action in query builder. +* [UIPQB-51](https://issues.folio.org/browse/UIPQB-51) Dropdown typeahead should use contains not starts with. diff --git a/src/QueryBuilder/QueryBuilder/QueryBuilderModal/RepeatableFields/RepeatableFields.js b/src/QueryBuilder/QueryBuilder/QueryBuilderModal/RepeatableFields/RepeatableFields.js index a558efa1..e4244c77 100644 --- a/src/QueryBuilder/QueryBuilder/QueryBuilderModal/RepeatableFields/RepeatableFields.js +++ b/src/QueryBuilder/QueryBuilder/QueryBuilderModal/RepeatableFields/RepeatableFields.js @@ -38,6 +38,10 @@ export const RepeatableFields = ({ source, setSource, getParamsSource, columns } setSource(filteredFields); }; + const onFilter = (value, dataOptions) => { + return dataOptions.filter(option => new RegExp(value, 'i').test(option.label)); + }; + const handleChange = (value, index, fieldName) => { const field = fieldOptions.find(o => o.value === value); const isField = fieldName === COLUMN_KEYS.FIELD; @@ -130,6 +134,7 @@ export const RepeatableFields = ({ source, setSource, getParamsSource, columns } placeholder={intl.formatMessage({ id: 'ui-plugin-query-builder.control.selection.placeholder' })} dataOptions={row.field.options} value={row.field.current} + onFilter={onFilter} onChange={(value) => handleChange(value, index, COLUMN_KEYS.FIELD)} />