Skip to content

Edit Response results in empty array (that leads to cf-conditional to fail) #421

@heri16

Description

@heri16

On the first flow, the cf-conditonal works normally because tagValue is [''] (array with emtpy string).

However, if the user edit a response, the cf-condition fails to work and always return false because tagValue is now [] (emtpy array).

We are testing for emtpy string with a RegExp cf-conditional for a tag that might be skipped/hidden due to a previous tag.

/**
* @name editTag
* go back in time and edit a tag.
*/
public editTag(tag: ITag): void {
this.ignoreExistingTags = false;
this.savedStep = this.step - 1;//save step
this.step = this.tags.indexOf(tag); // === this.currentTag
this.validateStepAndUpdate();
if(this.activeConditions && Object.keys(this.activeConditions).length > 0){
this.savedStep = -1;//don't save step, as we wont return
// clear chatlist.
this.cfReference.chatList.clearFrom(this.step + 1);
//reset from active tag, brute force
const editTagIndex: number = this.tags.indexOf(tag);
for(var i = editTagIndex + 1; i < this.tags.length; i++){
const tag: ITag | ITagGroup = this.tags[i];
tag.reset();
}
}
}

for (var i = 0; i < condition.conditionals.length; i++) {
var conditional: string | RegExp = condition.conditionals[i];
if(typeof tagValue !== "string"){
for (var j = 0; j < tagValue.length; j++) {
isValid = testValue(<string>tagValue[j], conditional);
if(isValid) break;
}
}else{
// string comparisson
isValid = testValue((<string[]>tagValue).toString(), conditional);
}
if(isValid) break;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions