Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separate context for rows in expression evaluation #979

Merged
merged 4 commits into from
Jan 24, 2025

Conversation

ivarne
Copy link
Member

@ivarne ivarne commented Dec 13, 2024

Frontend tests in ExpressionValidation app discovered that Expression validation failed on empty lists in data model.
This PR adds a check for empty list.

  • Add [DebuggerDisplay] for easier debugging
  • Change ComponentContext.ChildContexts from IEnumerable to List<>

Related Issue(s)

  • #{issue number}

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@ivarne ivarne changed the title Fix issue with Removal of hidden data the way it is used for expressi… Fix issue with Removal of hidden data the way it is used for expresion validation Dec 13, 2024
@ivarne ivarne added the bugfix Label Pull requests with bugfix. Used when generation releasenotes label Dec 13, 2024
@ivarne ivarne requested a review from bjosttveit December 13, 2024 11:36
…repeating groups

Previously this was implemented as a special case, but this makes the code simpler and fixes bugs I did not understand.
@ivarne ivarne force-pushed the bug/expression-validation-hidden-data branch from 92145ea to fd5d9c2 Compare December 18, 2024 21:05
Comment on lines +59 to +70
if (!includeHiddenRowChildren && isHidden)
{
if (context.Component is RepeatingGroupRowComponent or RepeatingGroupComponent)
{
var hiddenRows = await childContext.GetHiddenRows(state);
var currentRow = childContext.RowIndices?[^1];
var rowIsHidden = currentRow is not null && hiddenRows[currentRow.Value];
if (rowIsHidden)
if (context.Component.DataModelBindings.TryGetValue("group", out var groupBinding))
{
continue;
var indexedBinding = await state.AddInidicies(groupBinding, context);
hiddenModelBindings.Add(indexedBinding);
}
return;
}

}

Check notice

Code scanning / CodeQL

Nested 'if' statements can be combined Note

These 'if' statements can be combined.
@ivarne ivarne changed the title Fix issue with Removal of hidden data the way it is used for expresion validation Add separate context for rows in expression evaluation Dec 18, 2024
Copy link
Member

@bjosttveit bjosttveit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I don't know where it failed before, but this way of handling repeating group rows seems more robust 💪

@ivarne ivarne merged commit dd95a21 into main Jan 24, 2025
12 checks passed
@ivarne ivarne deleted the bug/expression-validation-hidden-data branch January 24, 2025 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Label Pull requests with bugfix. Used when generation releasenotes
Projects
Status: 🧪 Test
Development

Successfully merging this pull request may close these issues.

2 participants