nuPickers icon indicating copy to clipboard operation
nuPickers copied to clipboard

Lose picker value

Open Dallas-msc opened this issue 6 years ago • 8 comments

It is possible to lose the picker value by clicking Save/Publish button before the picker property editor has finished loading.

You can reproduce by selecting the document and then clicking the Save/Publish button immediately. If you do this before the ajax request to get the picker list has completed an empty value will be saved for that property.

We discovered this as we have a documentType with four Xml TypeaheadList Picker and there are documents where the list is quite long and take a second or two to load. These TypeAheadList Pickers are using the csv format to store the value.

A similar issue was reported for the Umbraco MNTP (U4-4848) that was fixed. The fix was only for the MNTP. There is also a reported issue for nuPickers (U4-6519).

Dallas-msc avatar Oct 25 '17 16:10 Dallas-msc

We found that $scope.SelectedOptions array doesn't have a value immediately when using CSV but selectedOptions is used to set $scope.model.value in the formSubmitting handler. If an editor clicks the save/publish button before selectedOptions gets set an empty value is saved.

Our fix was to set the $scope.selectedOptions when the variable is first instantiated. This stores the existing values and if an editor quickly clicks the save/publish button, nothing is lost. We build the array of { 'key': '', 'label': '' } objects and set the label to Loading ... . Once the ajax call is completed selectedOptions is updated with the returned values, has the correct label and the selected items are rendered.

Our understanding is that this would only affect the CSV data format because the other data formats don't need to make the ajax call - all of the details are stored in the value.

Dallas-msc avatar Oct 25 '17 21:10 Dallas-msc

@Dallas-msc any chance of a pull request, or sharing the code changes? Thanks :)

TimGeyssens avatar Feb 05 '18 09:02 TimGeyssens

Hi @TimGeyssens I created a Pull Request (#182) with the change we made to address this issue.

Dallas

Dallas-msc avatar Feb 05 '18 16:02 Dallas-msc

Ace, thanks!

TimGeyssens avatar Feb 05 '18 16:02 TimGeyssens

What's the progress on this issue? Losing values/data is a BIG problem and this isn't just an edge case, especially when using multiple pickers (that all require an AJAX request), large datasources (that take some time to process/load) or even a slow(er) internet connection or computer/tablet/mobile...

ronaldbarendse avatar Jan 15 '19 13:01 ronaldbarendse

Hi @ronaldbarendse we're just discussing this issue at the moment - hopefully get back to you with a solution soon.

Hendy avatar Jan 21 '19 16:01 Hendy

I wonder if in the "formSubmitting" event of each of the pickers we can check to see if it has loaded it's data - if not, then cancel the submit and trigger a notification ?

Hendy avatar Jan 21 '19 16:01 Hendy

@Hendy Is there any temporary fix for this problem? What if I change save to another format instead of CSV. Does that solve this issue?

abhilashca avatar Oct 23 '19 10:10 abhilashca