Several instances of Component - Behavior property

102 Views Asked by At

I created a component composed of a text input and a text label. The use of this component is to serve as input and also show an error (text label). The error can be anything such as blank text in the input or a duplicate value when compared with a collection. I have created a Custom behavior property thats linked to the OnChange of the text input in this way: Set(varErrorInfo,TextInputWithError.TextLabelOnChange());. I also setup this property to return a record in the form of { ErrorVisibility: true,ErrorText: "Email cannot be blank!"} I then use varErrorInfo to set the visibility and the Text of my text label inside my component.

In my canvas app I am setting the logic thats triggered on the TextLabelOnChange. This can be as simple as checking if the text inside my component (I am exposing it as an output property) is Blank or if its duplicate. Example:

If(
IsBlank(Self.Text),
{
    ErrorVisibility: true,
    ErrorText: "Email cannot be blank!"
};
//Notify("Email cannot be blank");
,
If(
    IsBlank(
        LookUp(
            Reviewers,
            Email = Self.Text
        )
    ),
    {
        ErrorVisibility: false,
        ErrorText: "No error"
    },
    {
        ErrorVisibility: true,
        ErrorText: "Email already exists"
    };
    //Notify("Email duplicate");
));

This works fine for one component but when I add another component it starts bugging out (either one of them only work). I tried to duplicate my component and then inserted a new instance of that component and it works fine. As far as I know different instances from the same component are isolated right (their variable, varErrorInfo) because it doesnt seem that way. Are different instances of the same component somehow interacting?

0

There are 0 best solutions below