OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Show BagPart content when the post request generates errors in the bagpart.

Open MikeAlhayek opened this issue 2 years ago • 8 comments

Is your feature request related to a problem? Please describe.

Assume we have a content-type (ex., Product) with a BagPart attached. The user create new or edits existing product and provids an invalid data for an items within the BagPart. The post request fails validation which is great! However, the bag part will be rendered in a collapsed state. So the user is left wondering where is the error until the user uncollapse the bag part and see the highlighted error

Describe the solution you'd like

I think when rendering the BagPart, we should uncollpase the bagpart if there is an error in any of it's contents.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

MikeAlhayek avatar Aug 03 '22 19:08 MikeAlhayek

Do you mean UI/UX improvement, right?

hishamco avatar Aug 03 '22 20:08 hishamco

yes. Specifically BagPart improvement

MikeAlhayek avatar Aug 03 '22 20:08 MikeAlhayek

Are you plan to open a PR?

hishamco avatar Aug 03 '22 23:08 hishamco

May be an error alert is suited for this case

hishamco avatar Aug 03 '22 23:08 hishamco

I’ll try if time permits. I think all we need to do is check the ModelState for and error where error-key starts with prefix of the BagPart. If any errors, we can add show class to the BagPart.

MikeAlhayek avatar Aug 03 '22 23:08 MikeAlhayek

If we have multiple items in bag part, this might not be obvious, that's why I prefer to show the error in a standard alert

hishamco avatar Aug 04 '22 00:08 hishamco

If we have more than one BagPart, it would be named part which will have different prefix. Plus, most drivers provide key to errors so we should just show the field validation. Otherwise, we’ll display the error twice “once as alert and other as around field”

Additionally, we are already showing the ValidationSummary But that would say something like “required title” yet the corresponding title field will be virtually hidden in the BagPart. The fields should really be visible at that point “only if there is error”. Another way we could do this, is post the state of each BagPart on post this way we can restore the same state if validation failed. But I think just showing the BagPart that container errors is best in this case

MikeAlhayek avatar Aug 04 '22 00:08 MikeAlhayek

It does highlight the errored input

ns8482e avatar Aug 04 '22 02:08 ns8482e

@ns8482e yes it highlights the fields but the widget block that contains the field will be collapsed and so the user does not see the highlighted fields unless they uncollapse the bag container. Here is a screencast to explain this issue better

BagPartWithErrors

MikeAlhayek avatar Sep 14 '22 21:09 MikeAlhayek

@MikeAlhayek

Is it possible that PR for this caused that all bag part items are uncollapsed everytime you edit content item, not only on error? It is kinda annoying, because when you have a lot of items, all of them are open in edit mode and you have to scroll a lot...

MikeKry avatar Nov 24 '22 16:11 MikeKry

@MikeKry it should not but I'll have to check it out when I have time.

MikeAlhayek avatar Nov 24 '22 20:11 MikeAlhayek

@MikeKry I suggest that open up a new issue with this. Perhaps, you want to explain the expected behavior that you want as well. Also, do you recall the behavior prior the BagPart change?

MikeAlhayek avatar Nov 25 '22 17:11 MikeAlhayek