Open Saeleas opened 12 months ago
That was not intentional. Please submit a pull request as you seem to have a fix.
Thank you!
Good to know! I (or maybe a colleague of mine) will make a pull request as soon as we can arrange some time to work on this.
Oops, I don't have dynamically added elements with visibleIf
in my use case and sadly there is no test for that :(
While I did this PR cause initially I had horrible cascading calls and load times of above 1 minute and was able to reduce it to like 4-5 seconds.
Maybe a solution would be to add a parameter to createProperty
if it should directly bind visbility or not and which defaults to true
? That potentially could fix all the custom widgets out in the wild doing something similiar. Basically, use only false
in ngOnChanges
for the rootProperty
creation and pass it also for the recursive calls to createProperty
in createProperty
itself.
Hello,
While doing an upgrade to the latest version (2.10.0) of
ngx-schema-form
from the version 2.8.4, we stumbled upon an issue.The issue concerns the
visibleIf
property when it's on an array. If we definevisibleIf
in a property that is inside on an item of an array, this is not processed when it is created (after callingaddItem
), if the property exists in themodel
then thevisibleIf
property is processed correctly.Here you will find an example on stackblitz: https://stackblitz.com/edit/angular-3b5bsy?file=src%2Fmain.ts
chooseOne
is used to decide whether to show a furtherstring
object or not. In the modelmyModel
we setup an object and thevisibleIf
property gets updated correctly. If we use theadd
button then thevisibleIf
property is always shown whether we choose any option forchooseOne
.We believe that this change in behaviour was intruduced here: https://github.com/guillotinaweb/ngx-schema-form/pull/454 calling
_bindVisibility()
fromngOnChanges
ofform.component.ts
instead of increateProperty
informpropertyfactory.ts
Was this change in behaviour intentional ? Or is it a undesired side effect ? If it was intentional, what would be the correct to define such property in our schema?
For the moment, in our implementation we had a custom component that implemented
ArrayWidget
, in this component we overrideaddItem
and there we callthis.formProperty._bindVisibility()
. This seems to solve this issue for the time being.Thanks for your help!