Search task form losing search criteria in accordions
Overview
Search task forms are losing search criteria from the advanced search form that have been entered in dynamically loaded accordions when not manually re-loading them after performing the search and before selecting a search task.
Reproduction steps
- Prepare a group of organization contacts that have relationships of the type "employer of" to several individuals
- Click on Contacts » Advanced Search
- Open the accordion Relationships
- Select the "Employee of" relationship type and add the previously created group of organizations in the "Target Contact(s) in Group" field (actually, any criterion within this accordion will do)
- Start the search, notice the number of results
- Select the "all x contacts" radio button for a search task
- Select a search task, e. g. the "Groups - Add Contacts"
Current behaviour
Notice that the task form will show a different number of affected contacts (a higher number) than were in the search result. This is because the search task form is not being passed the list of selected contacts from the search result, but the search criteria for querying the database again for the result. However, since the accordion is only being loaded if manually opened by clicking on it, the fields containing those criteria are not part of the form when submitting via selecting the search task. You can also see that when inspecting the request payload in your browser.
You can work around that if you open the accordion(s) with relevant criteria before selecting a search task, so that those fields will be part of the form and be submitted.
Expected behaviour
The task should be passed all search criteria and process the correct number of contacts. Thus, the search form for the result should already contain all relevant fields.
Environment information
- CiviCRM: 5.72.1
Comments
I'm not sure this is something to be fixed, now that SearchKit is the solution to everything, but this might be dangerous if you accidentally perform actions on your entire database of contacts.