Altinn / Altinn/app-frontend-react

Dynamic expression function to determine if a component is hidden or visible

Open
#2,518 0 comments 3 reactions 0 assignees View on GitHub
area/logic kind/feature-request
Dominant language
TypeScript
Stars
21
Forks
33
Avg merge
6d 23h
Merged PRs (30d)
3

Description

### Description

I would like a boolean dynamic expression [function](https://docs.altinn.studio/app/development/logic/expressions/) that evalutes whether a component is hidden or visible. This is useful in schema logic to evaluate if a component should be shown to the user or not, based on the visibility of other components.

Say I want to show an input-field, if, and only if, an earlier panel-component is shown, I would like something like this:

`ui/form/layouts/page1.json`

```json
{
"id": "mypanel",
"type": "Panel",
"variant": "info",
"showIcon": false,
"textResourceBindings": { },
"hidden": [ ...long expression to evaluate if this panel is shown or not, that I do not want to repeat in myinput...]
},
{
"id": "myinput",
"type": "Input",
"dataModelBindings": { },
"required": true,
"textResourceBindings": { },
"hidden": ["component-hidden", "mypanel"]
}
```

This function could also be used to check if `mypanel` is visible, i.e.:

* `[ "not", ["component-hidden", "mypanel"] ]`
* `[ "equals", ["component-hidden", "mypanel"], false ]`

### Additional Information

- Related: Altinn/altinn-studio#16764
- https://altinn.slack.com/archives/C02EJ9HKQA3/p1727704676459989

Contributor guide

Open the contributing guide

Research direction

Start with the dynamic expression documentation linked in the issue and the example structure in ui/form/layouts/page1.json. Search the frontend for the existing component-hidden expression and visibility handling; done means the expression can determine whether a referenced component is hidden or visible and supports the shown schema-logic use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.