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

Rendering checkboxes summary as string, when string is provided #310

Merged
merged 1 commit into from
Jul 4, 2022

Conversation

olemartinorg
Copy link
Contributor

Description

The summary page could end up rendering Checkboxes components by iterating each character and listing them line-by-line. This happens when the formData is provided as a string.

This quick-fix just renders the string instead, but we could also go the extra mile by hunting down why this happens and make sure Checkboxes components are always summarized with list inputs - although it is stored in formData as a comma-separated string.

Related Issue(s)

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)

… when showing a summary, but SummaryComponentSwitch.tsx assumed checkboxes always got a list of choices. When formData is string, we'll do the safe thing and just render that string. Otherwise each character in that string will be iterated.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 1, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

95.7% 95.7% Coverage
0.0% 0.0% Duplication

@@ -468,3 +469,11 @@ export function isDatePickerComponent(
): component is IDatePickerProps & ILayoutComponent {
return component.type.toLowerCase() === 'datepicker';
}

export function isCheckboxesComponent(
Copy link
Contributor

Choose a reason for hiding this comment

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

Add some tests? 😇

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I can do that, but I prefer to do it in a later PR. There are some changes to these functions in the hackaton/dynamics branch which I'd like to port over, and I've thought about possibly changing up some of the typings. The component types are a prime example of a case where discriminated unions works wonders - so with a change in that direction, these functions could be removed altogether, as TypeScript would give us the same functionality out of the box. I'll add it to my list of sabbatical TODOs.. 😉

Copy link
Contributor

@haakemon haakemon left a comment

Choose a reason for hiding this comment

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

LGTM (with the promise of added tests/simplified code which doesnt require tests to come during a sabbatical 😅)

@olemartinorg olemartinorg merged commit 0ca70bb into main Jul 4, 2022
@olemartinorg olemartinorg deleted the bug/257-checkboxes-summary branch July 4, 2022 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants