Altinn / app-frontend-react

Altinn application React frontend
BSD 3-Clause "New" or "Revised" License
14 stars 24 forks source link

RuleConfiguration does not work in v4 #2025

Open violaguttorm opened 1 month ago

violaguttorm commented 1 month ago

Description of the bug

In our app, we have a mix of RuleConfiguration and dynamic expressions for showing or hiding elements (due to dynamic expressions not existing when we began development on this app). However, after upgrading to v4 the elements affected by RuleConfiguration just simply do not show up any more, no matter if we swap "Hide" and "Show" on any given element. Even when using development tools to view hidden elements as greyed out, they do not show up.

If I delete the RuleConfiguration file, all elements show up as expected (but obviously all are shown).

Our app is https://altinn.studio/repos/brg/rrh-innrapportering (v4 branch is 379-migrer-til-v4) , but it might be tricky to get up and running locally due to multiple calls against Brønnøysundregistrenes internal apps which an outside computer can't necessarily reach.

Steps To Reproduce

  1. Write a rule in RuleConfiguration to show or hide an element, with a rule in RuleHandler.js
  2. Observe it not showing up.

Additional Information

No response

olemartinorg commented 3 weeks ago

Hmm, we have automatic tests for this, and in general RuleConfiguration definitely works in v4. However, as noted in the v4 documentation, we now properly support number/integer/boolean data types in data models with v4 and your rules may need updating. When looking at your RuleHandler.js file I immediately saw code that checks if something == "false", but false is now no longer the same as "false".

Please look over your RuleHandler.js and adjust it to match the data types used in v4+. One tip is throwing in a debugger;, opening developer tools in your browser (F12) and refreshing the page to make the debugger stop at that line - which easily lets you inspect the actual data types your rule handler gets from the data model.