Skip to content

chore: display error message to match grid label#4047

Open
JamalAlabdullah wants to merge 1 commit intomainfrom
4030-better-handle-how-error-messages-are-shown-for-components-using-innergrid
Open

chore: display error message to match grid label#4047
JamalAlabdullah wants to merge 1 commit intomainfrom
4030-better-handle-how-error-messages-are-shown-for-components-using-innergrid

Conversation

@JamalAlabdullah
Copy link
Contributor

@JamalAlabdullah JamalAlabdullah commented Mar 6, 2026

Description

Changed the way we display the validation error message to match grid label not input field.

Related Issue(s)

BEFORE Screenshot 2026-03-06 at 09 57 43
AFTER Screenshot 2026-03-06 at 09 57 53

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Summary by CodeRabbit

  • Refactor
    • Updated the layout and display of validation messages within components, improving the visual separation between content and validation feedback.

@JamalAlabdullah JamalAlabdullah added kind/other Pull requests containing chores/repo structure/other changes backport-ignore This PR is a new feature and should not be cherry-picked onto release branches labels Mar 6, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

Refactoring of the componentWithValidations rendering logic in ComponentStructureWrapper to conditionally structure the DOM: when labelGrid is absent, validation messages are rendered in a separate Flex component below the content; otherwise, they remain inline. Package configuration also updated.

Changes

Cohort / File(s) Summary
ComponentStructureWrapper rendering logic
src/layout/ComponentStructureWrapper.tsx
Restructured conditional rendering of validation messages: creates separate Flex wrapper for children and sibling Flex for validation when grid?.labelGrid is falsy; maintains original single Flex structure otherwise. Changes DOM separation and validation message placement.
Package configuration
package.json
Updated dependencies or configuration entries (+21/-1).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning PR description is incomplete: missing detailed change description, no related issue linked, no verification items marked as completed, and no labels added to the PR. Complete the PR description with: (1) detailed explanation of changes in the Description section; (2) related issue number in the Related Issue(s) section; (3) mark completed verification items with checkboxes; (4) add kind/* and backport* labels to the PR.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: display error message to match grid label' directly relates to the main change in the raw summary, which reworks validation message rendering based on labelGrid state.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 4030-better-handle-how-error-messages-are-shown-for-components-using-innergrid

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JamalAlabdullah JamalAlabdullah added kind/feature-request New feature or request kind/other Pull requests containing chores/repo structure/other changes and removed kind/other Pull requests containing chores/repo structure/other changes labels Mar 6, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/layout/ComponentStructureWrapper.tsx (1)

34-53: Consider making validation Flex sizing consistent with content Flex breakpoints.

The validation Flex (lines 46-51) only specifies xs and md breakpoints, while the content Flex (line 39) spreads grid?.innerGrid which may include sm, lg, or xl values. If innerGrid defines narrower widths at these breakpoints, the validation messages could end up wider than the content they relate to, potentially causing visual misalignment.

If the intent is for validation to always span full width regardless of innerGrid, consider being explicit about all breakpoints:

         <Flex
           item
-          size={{ xs: 12, md: 12 }}
+          size={{ xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }}
         >

Otherwise, if validation width should match content width, consider:

         <Flex
           item
-          size={{ xs: 12, md: 12 }}
+          size={{ xs: 12, ...grid?.innerGrid }}
         >
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/layout/ComponentStructureWrapper.tsx` around lines 34 - 53,
componentWithValidations renders two Flex blocks where the content Flex uses
size={{ xs: 12, ...grid?.innerGrid }} but the validation Flex hardcodes size={{
xs: 12, md: 12 }}, causing breakpoint mismatch; update the validation Flex
sizing to match the content Flex by either spreading grid?.innerGrid (size={{
xs: 12, ...grid?.innerGrid }}) or by explicitly providing the same breakpoints
you expect, so AllComponentValidations aligns with the Flex containing children
when showValidationMessages is true (refer to componentWithValidations, Flex,
AllComponentValidations, grid?.innerGrid, showValidationMessages, indexedId,
baseComponentId).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/layout/ComponentStructureWrapper.tsx`:
- Around line 34-53: componentWithValidations renders two Flex blocks where the
content Flex uses size={{ xs: 12, ...grid?.innerGrid }} but the validation Flex
hardcodes size={{ xs: 12, md: 12 }}, causing breakpoint mismatch; update the
validation Flex sizing to match the content Flex by either spreading
grid?.innerGrid (size={{ xs: 12, ...grid?.innerGrid }}) or by explicitly
providing the same breakpoints you expect, so AllComponentValidations aligns
with the Flex containing children when showValidationMessages is true (refer to
componentWithValidations, Flex, AllComponentValidations, grid?.innerGrid,
showValidationMessages, indexedId, baseComponentId).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a6993d1f-db03-494f-9126-c972544c2a20

📥 Commits

Reviewing files that changed from the base of the PR and between 5e931c9 and 59b9e42.

📒 Files selected for processing (1)
  • src/layout/ComponentStructureWrapper.tsx

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

@JamalAlabdullah JamalAlabdullah added the squad/utforming Issues that belongs to the named squad. label Mar 6, 2026
@JamalAlabdullah JamalAlabdullah moved this to 🔎 In review in Team Altinn Studio Mar 6, 2026
Copy link
Contributor

@lassopicasso lassopicasso left a comment

Choose a reason for hiding this comment

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

One comment about the width👍

I am unsure, but @Magnusrm mentioned that this change can perhaps be a breaking change for existing apps' layouts.
Maybe we should discuss this with the team on slack and see if someone has any more thoughts around this before we merget it.

{showValidationMessages && (
<Flex
item
size={{ xs: 12, md: 12 }}
Copy link
Contributor

@lassopicasso lassopicasso Mar 6, 2026

Choose a reason for hiding this comment

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

Suggested change
size={{ xs: 12, md: 12 }}
size={{ xs: 12, ...grid?.label?.innerGrid }}

I may be wrong, but shouldn't the validation message have the same width as label? Edit: you could test if your solution works with setting inner-grid on label, and if it doesnt change the width of error message, you can test my suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tested in repo ra0479-02 page 5 and it looks no effect happens and everything looks good , i tested in other pages also.
In the layout json files we have some json that has labelGrid and other do not have , so in line 34
const componentWithValidations = !grid?.labelGrid ? (. added logic to cover both status ,
and if you check the component Label.tsx line 57 it is set to 12 ; size={grid ?? { xs: 12 }} this match line 48 in this component ComponentStructureWrapper.tsx .
so the label Flex item uses size={{ xs: 12 }} and size={{ xs: 12, md: 12 }} uses the same, so i think your suggestion is allready included in the ternary logic.

@JamalAlabdullah JamalAlabdullah self-assigned this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-ignore This PR is a new feature and should not be cherry-picked onto release branches kind/feature-request New feature or request kind/other Pull requests containing chores/repo structure/other changes squad/utforming Issues that belongs to the named squad.

Projects

Status: 🔎 In review

Development

Successfully merging this pull request may close these issues.

Better handle how error messages are shown for components using innerGrid

2 participants