fix(Workflow): Search bar to select object is not working as expected (#16255)
Fixes Issue: #16188 **Bug:** Object Selection Dropdown was not working correctly when searching by object's name. This was happening only when `Search Records` action is selected. Other actions(Create, Delete, Update, Upsert) were working correclty(object search was working). **Reason:** `Search Records` action uses `WorkflowObjectDropdownContent` component which only filters based on `nameSingular` field in metadata (and doesnt search based on lable text). All other record action uses the `Select` component which filters by the label property (set to `labelProperty`). **Fix:** Updated the filtering logic of `WorkflowObjectDropdownContent` component to match the search text with label field also. I could't find any unit tests for the `WorkflowObjectDropdownContent` component (or any other component in workflow module). Let me know if I missed it and if tests need to be added for this. **Screenshot of working object search in Search Record** <img width="2056" height="1220" alt="image" src="https://github.com/user-attachments/assets/678d9806-899a-470c-9e82-b9f975d65950" />
This commit is contained in:
+22
-7
@@ -35,24 +35,39 @@ export const WorkflowObjectDropdownContent = ({
|
||||
objectMetadataItem.isActive && objectMetadataItem.isSystem,
|
||||
);
|
||||
|
||||
const matchesSearchFilter = (
|
||||
objectMetadataItem: (typeof objectMetadataItems)[number],
|
||||
searchInputLowerCase: string,
|
||||
) => {
|
||||
return (
|
||||
objectMetadataItem.nameSingular
|
||||
.toLowerCase()
|
||||
.includes(searchInputLowerCase) ||
|
||||
objectMetadataItem.labelSingular
|
||||
.toLowerCase()
|
||||
.includes(searchInputLowerCase) ||
|
||||
objectMetadataItem.labelPlural
|
||||
.toLowerCase()
|
||||
.includes(searchInputLowerCase)
|
||||
);
|
||||
};
|
||||
|
||||
const searchInputLowerCase = searchInputValue.toLowerCase();
|
||||
|
||||
const shouldShowAdvanced =
|
||||
showAdvancedOption &&
|
||||
!isSystemObjectsOpen &&
|
||||
(!isNonEmptyString(searchInputValue) ||
|
||||
searchInputValue.toLowerCase().includes('advanced'));
|
||||
searchInputLowerCase.includes('advanced'));
|
||||
|
||||
const filteredNonSystemObjects = nonSystemObjectMetadataItems.filter(
|
||||
(objectMetadataItem) =>
|
||||
objectMetadataItem.nameSingular
|
||||
.toLowerCase()
|
||||
.includes(searchInputValue.toLowerCase()),
|
||||
matchesSearchFilter(objectMetadataItem, searchInputLowerCase),
|
||||
);
|
||||
|
||||
const filteredSystemObjects = systemObjectMetadataItems.filter(
|
||||
(objectMetadataItem) =>
|
||||
objectMetadataItem.nameSingular
|
||||
.toLowerCase()
|
||||
.includes(searchInputValue.toLowerCase()),
|
||||
matchesSearchFilter(objectMetadataItem, searchInputLowerCase),
|
||||
);
|
||||
|
||||
const filteredObjects = isSystemObjectsOpen
|
||||
|
||||
Reference in New Issue
Block a user