From 65afad78ba02b2fa485dbe97d91447004ad2c03c Mon Sep 17 00:00:00 2001 From: Tomohisa Igarashi Date: Thu, 25 Apr 2024 22:02:00 -0400 Subject: [PATCH] fix: Typeahead expression search doesn't hit Bean Method with b Fixes: #1027 --- .../Form/expression/ExpressionEditor.test.tsx | 25 +++++++++++++++++++ .../Form/expression/ExpressionEditor.tsx | 7 ++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/components/Form/expression/ExpressionEditor.test.tsx b/packages/ui/src/components/Form/expression/ExpressionEditor.test.tsx index 670bd32db..32bfff0d7 100644 --- a/packages/ui/src/components/Form/expression/ExpressionEditor.test.tsx +++ b/packages/ui/src/components/Form/expression/ExpressionEditor.test.tsx @@ -84,4 +84,29 @@ describe('ExpressionEditor', () => { }); expect(inputElement).toHaveValue(''); }); + + it('find bean method with a word bean', async () => { + const language = ExpressionService.getDefinitionFromModelName( + languageCatalog as unknown as Record, + 'method', + ); + render( + , + ); + const inputElement = screen.getAllByRole('combobox')[0]; + await act(async () => { + fireEvent.change(inputElement, { target: { value: 'b' } }); + }); + const dropdownItems = screen.getAllByTestId(/expression-dropdownitem-.*/); + expect(dropdownItems).toHaveLength(6); + await act(async () => { + fireEvent.change(inputElement, { target: { value: 'bean' } }); + }); + const dropdownItems2 = screen.getAllByTestId(/expression-dropdownitem-.*/); + expect(dropdownItems2).toHaveLength(1); + }); }); diff --git a/packages/ui/src/components/Form/expression/ExpressionEditor.tsx b/packages/ui/src/components/Form/expression/ExpressionEditor.tsx index 59328a4fc..04252ac22 100644 --- a/packages/ui/src/components/Form/expression/ExpressionEditor.tsx +++ b/packages/ui/src/components/Form/expression/ExpressionEditor.tsx @@ -79,8 +79,11 @@ export const ExpressionEditor: FunctionComponent = ({ // Filter menu items based on the text input value when one exists if (filterValue) { - newSelectOptions = languageCatalogMap.filter((menuItem) => - String(menuItem.value).toLowerCase().includes(filterValue.toLowerCase()), + newSelectOptions = languageCatalogMap.filter( + (menuItem) => + String(menuItem.value).toLowerCase().includes(filterValue.toLowerCase()) || + String(menuItem.children).toLowerCase().includes(filterValue.toLowerCase()) || + String(menuItem.description).toLowerCase().includes(filterValue.toLowerCase()), ); // When no options are found after filtering, display 'No results found' if (!newSelectOptions.length) {