umbraco-doc-type-grid-editor icon indicating copy to clipboard operation
umbraco-doc-type-grid-editor copied to clipboard

Unable to save a component which previously failed validation

Open JakubHromada opened this issue 4 years ago • 13 comments

Hi, with the 1.2.6 upgrade I'm not able to save a newly created grid component which has previously failed a validation of required fields. I have also upgraded from Umbraco 8.7.0 to 8.9.1

Not sure if this is relevant but previously I wasn't able to save components which failed validation on Umbraco 8.7.0 with DocTypeGridEditor 1.2.4 but this was resolved with upgrading to grid editor 1.2.5 (while on Umbraco 8.7.0)

The newly added code in v1.2.6 below throws "cannot read property 'data' of undefined" error.

// cleanup the blueprint immediately $scope.model.node.id = err.data.id;

Thanks Jakub

JakubHromada avatar Dec 16 '20 13:12 JakubHromada

Thanks there should probably be a null conditional operator in err.data.id, so it looks like err?.data?.id, or only update $scope.model.node.id if err?.data != null

skttl avatar Jan 07 '21 06:01 skttl

Could this be related to this bug?

https://github.com/umbraco/Umbraco-CMS/issues/9563

AaronSadlerUK avatar Jan 07 '21 09:01 AaronSadlerUK

Looking at https://github.com/umbraco/Umbraco-CMS/pull/9300, I would say no. But could be worth trying to see if the fix also fixes this.

skttl avatar Jan 07 '21 10:01 skttl

So it's the 'err' that comes back as undefined once validation of required fields fails. Adding the suggested null and undefined check didn't help to fix this. After the check was added, the console started throwing a digest in progress error. There must be something bubbling up from Umbraco code. For now I'm probably forced to remove required fields validation for my components until this is fixed.

JakubHromada avatar Jan 07 '21 11:01 JakubHromada

If added an simple if-state to do the null check and than for me it works fine again. I've added an PR https://github.com/skttl/umbraco-doc-type-grid-editor/pull/236

inetzo avatar Jan 11 '21 12:01 inetzo

@inetzo what Umbraco version are you using?

JakubHromada avatar Jan 11 '21 13:01 JakubHromada

@JakubHromada 8.10.1

inetzo avatar Jan 11 '21 13:01 inetzo

Fixing the null check above did not fix for me either. :(

Umbraco version: 8.8.2 DTGE version: 1.2.6

But if anyone needs a temporary quick fix. In doctypegrideditor.controllers.js - right before the submit logic runs clear any existing form validations with the reset() method. After that it should allow you to re-submit the validation.

Unsure what the proper fix should be at this stage (not sure if the new flow of validation means the clearing of error should be happening at a different stage) - sorry didn't have time to look into it that deeply!

 function submit() {
              if ($scope.model.submit) {
                    serverValidationManager.reset(); // Clear all server validation errors before re-submitting

                    vm.saveButtonState = "busy";
                    $scope.model.node.name = "Dtge Temp: " + $scope.model.node.key;
                    $scope.model.node.variants[0].name = $scope.model.node.name
                    $scope.model.node.variants[0].save = true;
       ...
}

thisisjen avatar Jan 18 '21 04:01 thisisjen

From comments in https://github.com/skttl/umbraco-doc-type-grid-editor/issues/205 it appears there is a problem with blueprints being saved and validation passing even though it shouldn't. This happens for document types that include nested content properties.
This, combined with a semi-recent update to add a spinner to the save button appears to be causing the issue. (see https://github.com/skttl/umbraco-doc-type-grid-editor/commit/2fc81024ac2fdab54d703d2ae4163edb9bda7c81)

I realize the real issue is in the validation handling of blueprints, but I propose a small change to reset the save button when validation passes instead of relying on the dialog to close. That would fix the immediate problem. #239

tmog avatar Feb 09 '21 13:02 tmog

Hello @skttl, could this be reviewed as apparently Umbraco HQ managed to fix issue with nested content validation(and couple more issues related to Nested Content as stated in the comment above the one I linked)? I am using Our.Umbraco.DocTypeGridEditor v1.2.7 and I have upgraded Umbraco to the latest version but I am still not able to submit grid component with nested content property after missing fields have been provided. Although error message has been removed from the property, the top error over item itself still stays. Even when I remove item by clicking on the trash can and confirm delete action, the error is still there and I am not able to submit grid component. dtge-nested

Hope, validation of blueprint issue mentioned above has been resolved at Umbraco side so you would be able to review/fix issue if it is related to grideditor.

Thanks in advance, Srdjan

donsrle avatar Jun 11 '21 13:06 donsrle

I'll see if I can find some time to look into it, I can't say when, so you are very welcome to see if you can find the bug yourself and suggest a fix.

skttl avatar Jun 14 '21 12:06 skttl

Apparently there is still some bugs regarding validation of Nested Content... https://github.com/umbraco/Umbraco-CMS/issues/10520 I'll wait and see if fixing these, also fixes this one.

skttl avatar Jun 25 '21 07:06 skttl

Created an PR https://github.com/skttl/umbraco-doc-type-grid-editor/pull/267 for this.

inetzo avatar Nov 10 '21 17:11 inetzo