pnp/spfx-controls-react: issue with ListItemPicker rendering when calling onChanged in onSelectedIte

Copper Contributor


I am using a dynamicform with a field override. In this field override I use a ListItemPicker control with a custom onSelectedItem function.

Here I am calling the onChanged event because I want to store the selected value in a text (no lookup) field.

Now comes the issue when doing it like this the first time the dynamic form is loaded succesfully with the default (list) value in the ListeItemPicker, but when i click on the remove button the ListItemPicker value gets selected but not removed in the ListItemPicker control on first click. When repeating the click a second time the value gets removed.



Item selected but not removed


1 Reply
It sounds like there might be an issue with the timing of when the onSelectedItem function is being called and when the field is being updated. Here are a few suggestions to try:

1. Instead of calling the onChanged event directly from the onSelectedItem function, try setting a variable with the selected value and then using that variable to update the field in a separate function that is called on the onBlur or onValueChanged event of the field.

2. Try using a different field control, such as a DropDown control, to see if the issue persists.

3. If you're able to modify the ListItemPicker control, try adding a delay or a debounce function to the onSelectedItem function to ensure that the field is updated after the control has finished processing the selection.

4. Make sure that the field you're updating is not read-only or disabled, as this could prevent the value from being updated.

5. Check the console for any error messages or warnings that might be related to the issue.