This issue appears when a multi-select list already contains the top results (as returned by the API). Since selected items are not a part of the options list, they are removed from the options, and an empty list is generated. An empty list triggers a fetch until the options list is sufficiently populated or until the API says it has no more data.
The third parameter to fetchOptions is an offset forwarded to the API request. I believe options to be visible options only. Combined with FEATURE_SORTABLE_SELECT_HIDE_SELECTED=true it causes the duplicate options problem.
Edit the first resource and open the select field to observe the issue.
Possible Solution
I believe we'll have to separately track the running offset. The loadOptions function has a third argument called additional which we can utilize to track the running offset. Docs.
Please view the following view to see what the issue is about.
https://github.com/mitodl/ocw-studio/assets/71316217/7f686cd7-e81d-49f2-9a38-3d47d2ea022d
Please see this RC course for an example.
When does this occur?
This issue appears when a multi-select list already contains the top results (as returned by the API). Since selected items are not a part of the options list, they are removed from the options, and an empty list is generated. An empty list triggers a fetch until the options list is sufficiently populated or until the API says it has no more data.
What is the likely cause?
The following might be the source of the issue.
https://github.com/mitodl/ocw-studio/blob/312382d326c0b6475dc23cfaf68bf50ea30a1ed5/static/js/components/widgets/RelationField.tsx#L268
The third parameter to
fetchOptions
is an offset forwarded to the API request. I believeoptions
to be visible options only. Combined withFEATURE_SORTABLE_SELECT_HIDE_SELECTED=true
it causes the duplicate options problem.Expected Behavior
The options list does not show duplicates.
Current Behavior
The options list shows duplicates.
Steps to Reproduce
The environment must have the following variables
Possible Solution
I believe we'll have to separately track the running offset. The
loadOptions
function has a third argument calledadditional
which we can utilize to track the running offset. Docs.https://github.com/mitodl/ocw-studio/blob/312382d326c0b6475dc23cfaf68bf50ea30a1ed5/static/js/components/widgets/RelationField.tsx#L267