OrchardCore
OrchardCore copied to clipboard
Show BagPart content when the post request generates errors in the bagpart.
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.
Do you mean UI/UX improvement, right?
yes. Specifically BagPart
improvement
Are you plan to open a PR?
May be an error alert is suited for this case
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.
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
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
It does highlight the errored input
@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
@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 it should not but I'll have to check it out when I have time.
@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?