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

Moving ErrorReport component to the bottom of the form #346

Merged
merged 35 commits into from
Jul 28, 2022

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented Jul 20, 2022

Description

This change moved the ErrorReport component away from over the form modal to inside the modal, at the bottom of the form. Noteworthy changes:

  • This location is (usually) where navigation buttons are located, and these NavigationButtons will now be incorporated into the ErrorReport should they be located at the end of the currently active layout when there are any validation errors.
  • The ErrorReport now uses a Panel (currently the warning variant, as the error variant is not implemented yet)
  • When clicking the next navigation button, if validation messages are added to previous components in the form, you could end up seemingly being force-scrolled up a bit in the form (because added validation messages push the navigation buttons down). Now that validation messages are also displayed around these buttons, clicking the navigation buttons will maintain the position of the button(s) in the viewport when the ErrorReport shows up.
  • Errors listed in the ErrorReport are clickable (and tab-able). Clicking them sends you to the component with the validation error (if any).
  • The new functionality that navigates you to the correct page and scrolls the correct component into view (and focusing input/textarea fields) also works when clicking 'change' from a summary page.

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)

Ole Martin Handeland added 13 commits July 20, 2022 09:09
…ally lots) of validation messages to pop up in the form above the button. Until now it's been slightly confusing when you end up scrolled to a position that doesn't make much sense, but not that really harmful. When the button is now being surrounded by a panel giving you a descriptive message detailing your mistakes, it's more important to show that message. Adding some state used by the NavigationButtons.tsx to scroll back into the same position (relative to the button) in case the page change is rejected. This should keep the button in view even if the actual form gets considerably longer in the Y direction.
…x instead of on top of Presentation.tsx. Hopefully no other process step uses form validations. Instead of removing the bottom padding (as I did in v1), using negative a margin on FullWidthWrapper.tsx to consume it instead.
…it so that it scrolls the correct component into view and attempts to focus on it. Removing usages in radio/checkboxes, as these had no particular effect earlier - but now they would scroll the component into view. Implementing clickable errors in ErrorReport.tsx that automatically sends you to the correct page and scrolls the component into view for you.
# Conflicts:
#	src/altinn-app-frontend/src/components/message/ErrorReport.tsx
#	src/altinn-app-frontend/src/components/presentation/NavigationButtons.tsx
#	src/altinn-app-frontend/src/features/form/containers/Form.tsx
#	src/altinn-app-frontend/src/shared/containers/Presentation.tsx
…the viewport (i.e. you don't scroll away from it when multiple validation errors appear above)
@github-actions github-actions bot added the area/test related to automated and functional testing label Jul 20, 2022
Ole Martin Handeland added 7 commits July 21, 2022 11:00
…) so that TypeScript gives us an error in case a new variant gets added to the layout type string union without also being added to this switch/case.
…are above the viewport, and extending the test to verify that clicking the error message in ErrorReport scrolls you to the actual error message.
…urn behaviour of the Info panel type. Fixing this so the theoretically unreachable code can run when actual input doesn't adhere to TypeScript limitations.
@olemartinorg olemartinorg marked this pull request as ready for review July 21, 2022 11:36
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.

This looks great! 🥳 Left some minor comments to consider.

Ole Martin Handeland added 5 commits July 25, 2022 12:09
# Conflicts:
#	test/cypress/e2e/pageobjects/app-frontend.js
…to feat/100-errors-on-bottom-v2

# Conflicts:
#	test/cypress/e2e/pageobjects/app-frontend.js
…supposed to handle focus events such that you could trigger focus on the previous/next components in the layout (with the step argument). This breaks when dealing with repeating groups (ids with `myComponentId-0`), and it seems the code is not in use anymore - handleFocusUpdate() was declared in GenericComponent.tsx, but nobody ever uses it (anymore). Removing it entirely, as this should be re-implemented properly if needed. By using a simple reducer the updateFocus() action now works with componentIds pointing to a component in a repeating group.
Ole Martin Handeland added 5 commits July 26, 2022 14:53
…g tests in formLayout.test.ts (I recommend ignoring whitespace changes when reading this diff).
# Conflicts:
#	src/altinn-app-frontend/src/features/form/containers/Form.test.tsx
#	src/altinn-app-frontend/src/features/form/containers/Form.tsx
#	src/altinn-app-frontend/src/features/form/layout/update/updateFormLayoutSagas.test.ts
@sonarcloud
Copy link

sonarcloud bot commented Jul 28, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

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

64.1% 64.1% Coverage
0.0% 0.0% Duplication

@olemartinorg olemartinorg merged commit cb830f2 into main Jul 28, 2022
@olemartinorg olemartinorg deleted the feat/100-errors-on-bottom-v2 branch July 28, 2022 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test related to automated and functional testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants