Skip to content

Conversation

@Jondyr
Copy link
Member

@Jondyr Jondyr commented Nov 5, 2025

Description

Related Issue(s)

  • closes #{issue number}

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

Release Notes

  • New Features
    • Components across the application now support an optional dedicated summary title resource binding. When available, this new binding takes precedence over the standard title when rendering component summaries, providing more flexible title management and customization options for how component headers appear in summary views.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

📝 Walkthrough

Walkthrough

This pull request systematically updates summary and component files across the layout module to prioritize summaryTitle from text resource bindings, falling back to title when unavailable. Additionally, one file upload component is refactored to use a different hook for component retrieval and updates attachment tag logic accordingly.

Changes

Cohort / File(s) Summary
Standard Summary Components - Text Resource Binding Updates
src/layout/Accordion/SummaryAccordion.tsx, src/layout/Address/AddressSummary/AddressSummary.tsx, src/layout/Checkboxes/CheckboxesSummary.tsx, src/layout/Date/DateSummary.tsx, src/layout/Datepicker/DatepickerSummary.tsx, src/layout/Dropdown/DropdownSummary.tsx, src/layout/Grid/GridSummary.tsx, src/layout/Group/GroupSummary.tsx, src/layout/ImageUpload/ImageUploadSummary2/ImageUploadSummary2.tsx, src/layout/Input/InputSummary.tsx, src/layout/Likert/LikertComponent.tsx, src/layout/Likert/Summary2/LikertSummary.tsx, src/layout/List/ListComponent.tsx, src/layout/Map/Summary2/MapSummary.tsx, src/layout/MultipleSelect/MultipleSelectSummary.tsx, src/layout/Number/NumberSummary.tsx, src/layout/Option/OptionSummary.tsx, src/layout/OrganisationLookup/OrganisationLookupSummary.tsx, src/layout/Payment/PaymentSummary.tsx, src/layout/RadioButtons/RadioButtonsSummary.tsx, src/layout/RepeatingGroup/Summary2/RepeatingGroupSummary.tsx, src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx, src/layout/SimpleTable/ApiTableSummary.tsx, src/layout/SimpleTable/SimpleTableSummary.tsx, src/layout/Text/TextSummary.tsx, src/layout/TextArea/TextAreaSummary.tsx, src/layout/TimePicker/TimePickerSummary.tsx
Updates title resolution to prefer textResourceBindings?.summaryTitle when available, falling back to textResourceBindings?.title. Applied consistently across 27 files with no changes to control flow, component signatures, or rendering structure.
File Upload Component Refactoring
src/layout/FileUpload/AttachmentSummaryComponent2.tsx
Replaces useExternalItem hook with useItemWhenType to retrieve component with type narrowing to 'FileUpload' or 'FileUploadWithTag'. Updates hasTag derivation from component type instead of optional chaining. Moves minNumberOfAttachments access to retrieved component. Adds textResourceBindings to label with summaryTitle preference over title.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • FileUpload component refactoring (AttachmentSummaryComponent2.tsx): Verify hook replacement logic, type narrowing correctness, and that hasTag and minNumberOfAttachments derivations work as intended with the new component shape.
  • Pattern consistency: While the summaryTitle fallback pattern is homogeneous across 27 files, systematically verify that the fallback logic is correctly applied in each file (some use optional chaining ?., some use nullish coalescing ||, some use ternary operators).
  • Text resource availability: Confirm that summaryTitle binding is expected to be present in all affected text resource binding definitions.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is incomplete. It contains only the template structure with unchecked checkboxes and no actual descriptive content about the changes, objectives, or verification details. Fill in the Description section with a clear explanation of the changes. Mark or complete relevant verification/QA checkboxes. Reference the issue number in Related Issue(s) section.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: updating summary2 components to prioritize summaryTitle over title in text resource bindings, which is the primary focus across all modified files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/use-summaryTitle-when-available-in-summary2

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.

@Jondyr Jondyr added kind/bug Something isn't working backport This PR should be cherry-picked onto older release branches labels Nov 5, 2025
@Jondyr Jondyr moved this to 👷 In progress in Team Altinn Studio Nov 5, 2025
@Jondyr Jondyr self-assigned this Nov 5, 2025
@Jondyr Jondyr force-pushed the fix/use-summaryTitle-when-available-in-summary2 branch 2 times, most recently from 49f30a1 to e9de154 Compare November 12, 2025 11:59
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
35.1% Coverage on New Code (required ≥ 45%)
20.0% Duplication on New Code (required ≤ 3%)
34.11% Condition Coverage on New Code (required ≥ 45%)

See analysis details on SonarQube Cloud

@Jondyr Jondyr force-pushed the fix/use-summaryTitle-when-available-in-summary2 branch from e9de154 to aea8703 Compare December 17, 2025 06:41
@Jondyr Jondyr force-pushed the fix/use-summaryTitle-when-available-in-summary2 branch from aea8703 to 28eb2e0 Compare December 17, 2025 06:43
@Jondyr Jondyr marked this pull request as ready for review December 17, 2025 06:43
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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/layout/MultipleSelect/MultipleSelectSummary.tsx (1)

38-38: Works correctly; consider extracting for consistency.

The inline usage is functionally correct but differs from the pattern used in other components (e.g., CheckboxesSummary.tsx line 24, DropdownSummary.tsx line 20, RadioButtonsSummary.tsx line 20), which extract the title to a variable first.

For consistency with the rest of the codebase, consider this refactor:

   const { textResourceBindings, required } = useItemWhenType(targetBaseComponentId, 'MultipleSelect');
   const displayValues = useMultipleValuesForSummary(targetBaseComponentId);
+  const title = textResourceBindings?.summaryTitle || textResourceBindings?.title;

   return (
     <SummaryFlex
       targetBaseId={targetBaseComponentId}
       content={
         displayValues.length === 0
           ? required
             ? SummaryContains.EmptyValueRequired
             : SummaryContains.EmptyValueNotRequired
           : SummaryContains.SomeUserContent
       }
     >
       <MultipleValueSummary
-        title={<Lang id={textResourceBindings?.summaryTitle || textResourceBindings?.title} />}
+        title={<Lang id={title} />}
         baseComponentId={targetBaseComponentId}
         displayValues={displayValues}
         showAsList={showAsList}
         isCompact={isCompact}
         emptyFieldText={overrides?.emptyFieldText}
       />
     </SummaryFlex>
src/layout/Group/GroupSummary.tsx (1)

61-62: Simplify redundant title variable.

The new title variable (line 61) already implements the fallback logic summaryTitle || title, but line 90 still references summaryTitle ?? title. Since title already handles the fallback, you can simplify line 90 to just use the title variable directly, eliminating the redundancy.

Apply this diff:

-            <Lang id={summaryTitle ?? title} />
+            <Lang id={title} />

Alternatively, if you prefer to keep the existing pattern, you can remove the new title variable and keep line 90 as-is.

Also applies to: 90-90

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d68844 and 28eb2e0.

📒 Files selected for processing (28)
  • src/layout/Accordion/SummaryAccordion.tsx (2 hunks)
  • src/layout/Address/AddressSummary/AddressSummary.tsx (2 hunks)
  • src/layout/Checkboxes/CheckboxesSummary.tsx (1 hunks)
  • src/layout/Date/DateSummary.tsx (1 hunks)
  • src/layout/Datepicker/DatepickerSummary.tsx (1 hunks)
  • src/layout/Dropdown/DropdownSummary.tsx (1 hunks)
  • src/layout/FileUpload/AttachmentSummaryComponent2.tsx (3 hunks)
  • src/layout/Grid/GridSummary.tsx (1 hunks)
  • src/layout/Group/GroupSummary.tsx (1 hunks)
  • src/layout/ImageUpload/ImageUploadSummary2/ImageUploadSummary2.tsx (1 hunks)
  • src/layout/Input/InputSummary.tsx (1 hunks)
  • src/layout/Likert/LikertComponent.tsx (1 hunks)
  • src/layout/Likert/Summary2/LikertSummary.tsx (5 hunks)
  • src/layout/List/ListComponent.tsx (1 hunks)
  • src/layout/Map/Summary2/MapSummary.tsx (1 hunks)
  • src/layout/MultipleSelect/MultipleSelectSummary.tsx (1 hunks)
  • src/layout/Number/NumberSummary.tsx (1 hunks)
  • src/layout/Option/OptionSummary.tsx (1 hunks)
  • src/layout/OrganisationLookup/OrganisationLookupSummary.tsx (1 hunks)
  • src/layout/Payment/PaymentSummary.tsx (1 hunks)
  • src/layout/RadioButtons/RadioButtonsSummary.tsx (1 hunks)
  • src/layout/RepeatingGroup/Summary2/RepeatingGroupSummary.tsx (1 hunks)
  • src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx (1 hunks)
  • src/layout/SimpleTable/ApiTableSummary.tsx (1 hunks)
  • src/layout/SimpleTable/SimpleTableSummary.tsx (1 hunks)
  • src/layout/Text/TextSummary.tsx (1 hunks)
  • src/layout/TextArea/TextAreaSummary.tsx (1 hunks)
  • src/layout/TimePicker/TimePickerSummary.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid using any type or type casting (as type) in TypeScript code; improve typing by avoiding casts and anys when refactoring
Use objects for managing query keys and functions, and queryOptions for sharing TanStack Query patterns across the system for central management

Files:

  • src/layout/Option/OptionSummary.tsx
  • src/layout/List/ListComponent.tsx
  • src/layout/Date/DateSummary.tsx
  • src/layout/RepeatingGroup/Summary2/RepeatingGroupSummary.tsx
  • src/layout/TimePicker/TimePickerSummary.tsx
  • src/layout/Text/TextSummary.tsx
  • src/layout/ImageUpload/ImageUploadSummary2/ImageUploadSummary2.tsx
  • src/layout/SimpleTable/ApiTableSummary.tsx
  • src/layout/Datepicker/DatepickerSummary.tsx
  • src/layout/Number/NumberSummary.tsx
  • src/layout/Input/InputSummary.tsx
  • src/layout/Likert/Summary2/LikertSummary.tsx
  • src/layout/Map/Summary2/MapSummary.tsx
  • src/layout/Address/AddressSummary/AddressSummary.tsx
  • src/layout/Group/GroupSummary.tsx
  • src/layout/Payment/PaymentSummary.tsx
  • src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx
  • src/layout/Likert/LikertComponent.tsx
  • src/layout/Accordion/SummaryAccordion.tsx
  • src/layout/OrganisationLookup/OrganisationLookupSummary.tsx
  • src/layout/FileUpload/AttachmentSummaryComponent2.tsx
  • src/layout/Checkboxes/CheckboxesSummary.tsx
  • src/layout/SimpleTable/SimpleTableSummary.tsx
  • src/layout/MultipleSelect/MultipleSelectSummary.tsx
  • src/layout/RadioButtons/RadioButtonsSummary.tsx
  • src/layout/Grid/GridSummary.tsx
  • src/layout/Dropdown/DropdownSummary.tsx
  • src/layout/TextArea/TextAreaSummary.tsx
{**/*.module.css,**/*.{ts,tsx}}

📄 CodeRabbit inference engine (CLAUDE.md)

Use CSS Modules for component styling and leverage Digdir Design System components when possible

Files:

  • src/layout/Option/OptionSummary.tsx
  • src/layout/List/ListComponent.tsx
  • src/layout/Date/DateSummary.tsx
  • src/layout/RepeatingGroup/Summary2/RepeatingGroupSummary.tsx
  • src/layout/TimePicker/TimePickerSummary.tsx
  • src/layout/Text/TextSummary.tsx
  • src/layout/ImageUpload/ImageUploadSummary2/ImageUploadSummary2.tsx
  • src/layout/SimpleTable/ApiTableSummary.tsx
  • src/layout/Datepicker/DatepickerSummary.tsx
  • src/layout/Number/NumberSummary.tsx
  • src/layout/Input/InputSummary.tsx
  • src/layout/Likert/Summary2/LikertSummary.tsx
  • src/layout/Map/Summary2/MapSummary.tsx
  • src/layout/Address/AddressSummary/AddressSummary.tsx
  • src/layout/Group/GroupSummary.tsx
  • src/layout/Payment/PaymentSummary.tsx
  • src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx
  • src/layout/Likert/LikertComponent.tsx
  • src/layout/Accordion/SummaryAccordion.tsx
  • src/layout/OrganisationLookup/OrganisationLookupSummary.tsx
  • src/layout/FileUpload/AttachmentSummaryComponent2.tsx
  • src/layout/Checkboxes/CheckboxesSummary.tsx
  • src/layout/SimpleTable/SimpleTableSummary.tsx
  • src/layout/MultipleSelect/MultipleSelectSummary.tsx
  • src/layout/RadioButtons/RadioButtonsSummary.tsx
  • src/layout/Grid/GridSummary.tsx
  • src/layout/Dropdown/DropdownSummary.tsx
  • src/layout/TextArea/TextAreaSummary.tsx
🧠 Learnings (1)
📚 Learning: 2025-10-14T09:01:40.985Z
Learnt from: lassopicasso
Repo: Altinn/app-frontend-react PR: 3654
File: src/layout/ImageUpload/ImageUploadSummary2/ImageUploadSummary2.tsx:49-53
Timestamp: 2025-10-14T09:01:40.985Z
Learning: In the Altinn app-frontend-react codebase, when data integrity is guaranteed through business logic and parent components guard rendering (e.g., `storedImage ? <Component /> : undefined`), non-null assertions on guaranteed fields like `storedImage!.data?.filename` are acceptable and preferred over optional chaining with fallbacks.

Applied to files:

  • src/layout/ImageUpload/ImageUploadSummary2/ImageUploadSummary2.tsx
🧬 Code graph analysis (4)
src/layout/Likert/Summary2/LikertSummary.tsx (1)
src/features/language/Lang.tsx (1)
  • Lang (15-23)
src/layout/Payment/PaymentSummary.tsx (2)
src/utils/layout/useNodeItem.ts (1)
  • useItemWhenType (15-33)
src/layout/Payment/PaymentReceiptDetails/PaymentReceiptDetails.tsx (1)
  • PaymentReceiptDetails (68-197)
src/layout/FileUpload/AttachmentSummaryComponent2.tsx (1)
src/utils/layout/useNodeItem.ts (1)
  • useItemWhenType (15-33)
src/layout/MultipleSelect/MultipleSelectSummary.tsx (1)
src/features/language/Lang.tsx (1)
  • Lang (15-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Install
  • GitHub Check: Type-checks, eslint, unit tests and SonarCloud
  • GitHub Check: Install
🔇 Additional comments (27)
src/layout/RepeatingGroup/Summary2/RepeatingGroupSummary.tsx (1)

39-39: LGTM! Consistent use of summaryTitle with fallback.

The change correctly implements the pattern of preferring summaryTitle when available, falling back to title. The derived title is used consistently throughout the component.

src/layout/RadioButtons/RadioButtonsSummary.tsx (1)

20-20: LGTM! Title precedence implemented correctly.

The change follows the established pattern and is used appropriately at line 34 with proper undefined handling.

src/layout/List/ListComponent.tsx (1)

111-111: LGTM! Consistent summaryTitle precedence.

The change is correctly implemented and the derived title variable is used consistently throughout the component at lines 189, 214, and 258.

src/layout/Dropdown/DropdownSummary.tsx (1)

20-20: LGTM! Correct implementation of summaryTitle precedence.

The change follows the established pattern and is used properly at line 34 with appropriate undefined handling.

src/layout/Checkboxes/CheckboxesSummary.tsx (1)

24-24: LGTM! Follows the consistent pattern.

The change correctly prioritizes summaryTitle over title and is used appropriately in the component.

src/layout/Grid/GridSummary.tsx (1)

57-57: LGTM! Correct summaryTitle precedence for grid caption.

The change properly implements the pattern and the derived title is used correctly at line 152 in the table caption.

src/layout/Input/InputSummary.tsx (1)

20-20: LGTM! Proper fallback pattern for summary title.

The change correctly prioritizes summaryTitle when available, falling back to title. This aligns with the PR objective and maintains backward compatibility.

src/layout/TextArea/TextAreaSummary.tsx (1)

20-20: LGTM! Consistent with the summaryTitle pattern.

The implementation correctly uses summaryTitle with fallback to title, matching the approach used across other summary components in this PR.

src/layout/Date/DateSummary.tsx (1)

20-20: LGTM! Follows the established pattern.

The title resolution correctly implements the summaryTitle preference with proper fallback, consistent with other components in this PR.

src/layout/Map/Summary2/MapSummary.tsx (1)

30-30: LGTM! Correctly implements summaryTitle preference.

The change aligns with the PR-wide pattern of prioritizing summaryTitle with a fallback to title.

src/layout/Text/TextSummary.tsx (1)

20-20: LGTM! Consistent implementation.

The title resolution properly uses summaryTitle with fallback to title, maintaining consistency across the codebase.

src/layout/OrganisationLookup/OrganisationLookupSummary.tsx (1)

21-21: LGTM! Aligns with the summaryTitle pattern.

The implementation correctly prioritizes summaryTitle over title, consistent with the changes across this PR.

src/layout/Payment/PaymentSummary.tsx (1)

17-17: LGTM! Correct use of summaryTitle with fallback.

The fallback pattern summaryTitle || title is correctly implemented, aligning with the PR objective.

src/layout/TimePicker/TimePickerSummary.tsx (1)

20-20: LGTM! Proper implementation of summaryTitle precedence.

The change correctly uses summaryTitle when available, falling back to title, consistent with the pattern established across this PR.

src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx (1)

40-40: LGTM - Consistent title resolution pattern.

The change correctly prioritizes summaryTitle when available, falling back to title. This aligns with the PR objective and follows the pattern used across all summary components.

src/layout/Datepicker/DatepickerSummary.tsx (1)

20-20: LGTM - Title fallback implemented correctly.

src/layout/SimpleTable/SimpleTableSummary.tsx (1)

23-23: LGTM - Consistent with the broader pattern.

src/layout/ImageUpload/ImageUploadSummary2/ImageUploadSummary2.tsx (1)

19-19: LGTM - Title resolution follows the established pattern.

src/layout/Address/AddressSummary/AddressSummary.tsx (1)

18-19: LGTM - Triple fallback pattern is appropriate here.

The Address component correctly adds summaryTitle to the destructuring and uses a three-level fallback (summaryTitle || title || 'address_component.address'). The default fallback to 'address_component.address' ensures the address field always has a meaningful label, which is appropriate for this component.

Also applies to: 42-42

src/layout/Option/OptionSummary.tsx (1)

20-20: LGTM - Follows the consistent pattern.

src/layout/SimpleTable/ApiTableSummary.tsx (1)

22-22: LGTM - Consistent title resolution.

src/layout/Number/NumberSummary.tsx (1)

20-20: LGTM - Final file follows the consistent pattern.

All 8 files have been updated consistently to prioritize summaryTitle over title. The implementation is clean and aligns with the PR objective.

src/layout/Likert/Summary2/LikertSummary.tsx (2)

37-37: LGTM! Consistent implementation of summaryTitle fallback.

The title derivation correctly prioritizes summaryTitle over title and is used consistently across all Lang component instances in LikertSummary.

Also applies to: 46-46, 69-69


112-112: LGTM! Consistent pattern in LikertRowSummary.

The same summaryTitle fallback pattern is correctly applied in the nested LikertRowSummary component.

Also applies to: 124-124

src/layout/Accordion/SummaryAccordion.tsx (1)

36-36: LGTM! Clean summaryTitle fallback in both components.

Both SummaryAccordionComponent and SummaryAccordionComponent2 correctly implement the summaryTitle fallback pattern with proper string conversion via langAsString.

Also applies to: 63-63

src/layout/FileUpload/AttachmentSummaryComponent2.tsx (2)

19-23: LGTM! Improved type safety with useItemWhenType.

The switch from useExternalItem to useItemWhenType with a type guard provides better type narrowing and will throw early if an unexpected component type is encountered. The derivation of hasTag from the component type is cleaner and more explicit.


37-37: LGTM! Consistent summaryTitle pattern and cleaner property access.

The direct access to component.minNumberOfAttachments and the summaryTitle fallback in textResourceBindings align with the PR objective and simplify the code.

Also applies to: 51-53


const indexedId = useIndexedId(baseComponentId);
const title = textResourceBindings?.title;
const title = textResourceBindings?.summaryTitle || textResourceBindings?.title;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Title derivation is correct, but update aria-labelledby check.

The change at line 32 correctly implements summaryTitle precedence. However, line 64 still references textResourceBindings?.title for the aria-labelledby attribute, which creates an accessibility bug.

Issue: If summaryTitle exists but title does not, the component will display a heading (line 51 uses the derived title), but aria-labelledby will be undefined because the check at line 64 evaluates textResourceBindings?.title.

Apply this diff to fix the accessibility issue:

         <div
           role='group'
           className={classes.likertMobileGroup}
-          aria-labelledby={textResourceBindings?.title ? getLabelId(indexedId) : undefined}
+          aria-labelledby={title ? getLabelId(indexedId) : undefined}
           aria-describedby={textResourceBindings?.description ? getDescriptionId(indexedId) : undefined}
         >

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/layout/Likert/LikertComponent.tsx around lines 32 and 64, the component
now derives title as "textResourceBindings?.summaryTitle ||
textResourceBindings?.title" (line 32) but the aria-labelledby check at line 64
still tests textResourceBindings?.title, causing aria-labelledby to be omitted
when only summaryTitle is present; change the aria-labelledby condition to
reference the derived title (or test textResourceBindings?.summaryTitle ||
textResourceBindings?.title) so the attribute is set whenever the displayed
heading exists, ensuring accessibility.

Comment on lines 9 to +10
const title = useItemWhenType(targetBaseComponentId, 'Payment').textResourceBindings?.title;
const summaryTitle = useItemWhenType(targetBaseComponentId, 'Payment').textResourceBindings?.summaryTitle;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Refactor to eliminate duplicate hook calls.

Calling useItemWhenType twice with identical arguments is inefficient and violates React best practices. The hook internally calls multiple other hooks, so this causes unnecessary duplicate computations.

Apply this diff to call the hook once:

-  const title = useItemWhenType(targetBaseComponentId, 'Payment').textResourceBindings?.title;
-  const summaryTitle = useItemWhenType(targetBaseComponentId, 'Payment').textResourceBindings?.summaryTitle;
+  const { textResourceBindings } = useItemWhenType(targetBaseComponentId, 'Payment');
+  const title = textResourceBindings?.title;
+  const summaryTitle = textResourceBindings?.summaryTitle;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const title = useItemWhenType(targetBaseComponentId, 'Payment').textResourceBindings?.title;
const summaryTitle = useItemWhenType(targetBaseComponentId, 'Payment').textResourceBindings?.summaryTitle;
const { textResourceBindings } = useItemWhenType(targetBaseComponentId, 'Payment');
const title = textResourceBindings?.title;
const summaryTitle = textResourceBindings?.summaryTitle;
🤖 Prompt for AI Agents
In src/layout/Payment/PaymentSummary.tsx around lines 9 to 10, the code calls
useItemWhenType(targetBaseComponentId, 'Payment') twice which duplicates hook
work and is inefficient; replace the two calls by calling useItemWhenType once,
store its return in a local variable (e.g., paymentItem), then derive title and
summaryTitle from paymentItem?.textResourceBindings?.title and
paymentItem?.textResourceBindings?.summaryTitle respectively, preserving the
same optional chaining/null checks.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
35.6% Coverage on New Code (required ≥ 45%)
20.5% Duplication on New Code (required ≤ 3%)
34.58% Condition Coverage on New Code (required ≥ 45%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR should be cherry-picked onto older release branches kind/bug Something isn't working

Projects

Status: 👷 In progress

Development

Successfully merging this pull request may close these issues.

summaryTitle not replacing title in RepeatingGroup

1 participant