From f19395709664f296b455f7438226d1bebcc9b10e Mon Sep 17 00:00:00 2001 From: John Oleksowicz Date: Wed, 15 Dec 2021 15:55:44 -0600 Subject: [PATCH] Search based on beginning of words Instead of the search results simply looking to see if a word contains the term searched for, this makes it so the term has to match the beginning of one of the words. For example, let's say the options were: - First name - Confirmation time Previously, a search for "n" would return both, because there is an n in the word Confirmation. With this change, only First name would match because the word name starts with n. See the Jira ticket for discussion. [MAILPOET-3958] --- .../step_data_manipulation/generate_column_selection.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/js/src/subscribers/importExport/import/step_data_manipulation/generate_column_selection.jsx b/assets/js/src/subscribers/importExport/import/step_data_manipulation/generate_column_selection.jsx index d7fcf82683..c793d7a3e7 100644 --- a/assets/js/src/subscribers/importExport/import/step_data_manipulation/generate_column_selection.jsx +++ b/assets/js/src/subscribers/importExport/import/step_data_manipulation/generate_column_selection.jsx @@ -25,7 +25,8 @@ export default () => { // `name` is the label displayed to users const matchedChildren = data.children.filter((child) => { const label = child.name.toLowerCase(); - return label.includes(searchTerm); + const words = label.split(' '); + return words.some((word) => word.startsWith(searchTerm)); }); if (matchedChildren.length === 0) { // Returning null prevent the entire optgroup from being displayed