Closed rexebin closed 2 years ago
Hey @rexebin this looks pretty good. It took me a while since it changed all the formatting of the class but overall looks well done.
One of the reasons I didn't inherited InputBase
from the start was the limitation of using elements only inside an EditContext
. Looking at it now, I wonder if people actually use it outside an EditForm at all. On the plus side, it could handle the Css changes, validations and easier access to EditContext
and FieldIdentifier
. The downside would be changing the current Value mechanics to update. I can take a quick look into that and see how it works out
@jscasca I am sorry for the formatting, I should not have done it. My editor did it automatically and I didn't pay attention when committing.
I am not sure how the changes affect current value mechanics, as far as I understand it, the changes only affect ClassName
and trigger validations.
@rexebin changing the current Value mechanics was one of the downsides of using InputBase
I was talking about. I'm happy to go with your solution instead of using InputBase
. The only things I would change are:
For
to Field
instead (In a validation it makes sense to have "For" the value you are validating but it feels like in an input field makes more sense to name the field)OnChangeContent
@jscasca what you mean by "change the notify to trigger from OnChangeContent
", do you mean change the JSInvokable method from OnChange
to OnChangeContent
?
Ok, I understand what you mean now. In this case, there is no need to hook up to change
and input
events. Both events will trigger OnChangeContent
.
There is a problem with trigger validation in OnChangeContent
: 1. the validation will be triggered at the very beginning when the user has not changed anything. 2. it will trigger on input as well and this may make the Editor's validation behaviour differ from other form components when they trigger validation only on change/lost focus.
@jscasca To trigger validation only on change or on input, I added two flags. Please review and see if there is another more elegant way to deal with the issue. Thank you!