Skip to content

Conversation

@JamalAlabdullah
Copy link
Contributor

@JamalAlabdullah JamalAlabdullah commented Dec 17, 2025

Description

Changes:

Adds a new opt-in property compactButtons to the RepeatingGroup component's edit configuration. When enabled, edit = Rediger and delete= Slett buttons in the table view display only icons (without text labels) in view mode, while still showing full text labels when a row is in edit mode. This provides a cleaner, more compact table UI when there are many columns or limited horizontal space.

How to Use

Add compactButtons: true to the edit property of your RepeatingGroup configuration in the layout JSON:

 {
        "id": "RepeatingGroup",
        "type": "RepeatingGroup",
        "textResourceBindings": {
          "title": "Repeterende Gruppe",
          "description": "Beskrivelse av repeterende gruppe"
        },
        "dataModelBindings": {
          "group": "repeatingGroup"
        },
        "hidden": false,
        "edit": {
        "compactButtons": true
       },
        "children": [
          "RepeatingGroup-Input-Name",
          "RepeatingGroup-Input-Points",
          "RepeatingGroup-Input-Date"
        ]
      },

SOLUTION:

Screen.Recording.2025-12-18.at.12.52.34.mov

Related Issue(s)

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

  • New Features

    • Added configurable "compact button" mode for repeating groups: action buttons show icons only in view mode and display text labels during edit mode.
  • Tests

    • Added tests covering compact button behavior in view and edit states and included necessary text resources for localization.

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

@JamalAlabdullah JamalAlabdullah added the backport-ignore This PR is a new feature and should not be cherry-picked onto release branches label Dec 17, 2025
@JamalAlabdullah JamalAlabdullah linked an issue Dec 17, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

📝 Walkthrough

Walkthrough

Adds a new compactButtons option to RepeatingGroup config and implements logic to render edit/delete buttons as icon-only or icon+text depending on mode (view vs edit) and device/ARIA state; tests and manifest updates included.

Changes

Cohort / File(s) Summary
Configuration
src/layout/RepeatingGroup/config.ts
Adds optional compactButtons: boolean to IGroupEditProperties with title and description controlling icon-only vs text display for edit/delete buttons.
Table row implementation
src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsx
Introduces compactButtons derived from group edit props, passes it into EditElement/DeleteElement, and uses showText logic (based on compactButtons, ariaExpanded, and mobile conditions) to conditionally render button text.
Tests
src/layout/RepeatingGroup/Table/RepeatingGroupTable.test.tsx
Adds tests covering compactButtons behavior: verifying icon-only view mode and text-visible edit mode; extends mocked text resources (general.delete, general.edit_alt, general.save_and_close).
Manifest / package
manifest_file, package.json
Updates included in manifest and package metadata (changes indicated in diff).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review showText conditional logic across desktop/mobile/ARIA cases for correctness and edge cases.
  • Verify compactButtons type and default handling in config and that the prop is propagated without breaking existing flows.
  • Check updated tests for proper coverage and localization resource usage.
  • Inspect manifest/package changes for unintended version or metadata bumps.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a configuration option to remove edit and delete button texts in view mode and show them in edit mode, which aligns with the implementation of the compactButtons feature.
Description check ✅ Passed The PR description provides a comprehensive overview including the feature purpose, implementation details, usage example, related issue reference, and verification checklist with manual testing and unit tests marked as completed.
✨ 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 1164-mer-kompakt-visning-av-knappene-lagre-og-slett

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 changed the title fix: Remove edit and delete buttons texts in view mode and show them … fix: Remove edit and delete buttons texts in view mode and show them in the edit one. Dec 17, 2025
@JamalAlabdullah JamalAlabdullah added the kind/bug Something isn't working label Dec 17, 2025
@olemartinorg
Copy link
Contributor

@JamalAlabdullah The original issue is a feature request, so I would think this was meant to be an opt-in feature that could be toggled on the RepeatingGroup component. I see you've labelled this PR a bugfix and made it the default setting, and I think some service owners will consider a change like this a breaking one. As we also have features to override the text on these buttons, we should probably have a larger discussion about this if the intention is making this the new default.

@JamalAlabdullah
Copy link
Contributor Author

JamalAlabdullah commented Dec 17, 2025

@JamalAlabdullah The original issue is a feature request, so I would think this was meant to be an opt-in feature that could be toggled on the RepeatingGroup component. I see you've labelled this PR a bugfix and made it the default setting, and I think some service owners will consider a change like this a breaking one. As we also have features to override the text on these buttons, we should probably have a larger discussion about this if the intention is making this the new default.

Ok understood, I will revert the changes, should i put it in blocked until we take another discussion ?

@olemartinorg
Copy link
Contributor

I would just make it an optional feature. Dig around in the RepeatingGroup/config.ts where the config options are defined - you can define this as a boolean at first (making it a boolean expression will take some more work to implement). I would think it's best to have this inside the edit config group, maybe edit.compactButtons.

Just ping me on slack if anything is unclear, I can assist if needed! 🙏

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: 0

🧹 Nitpick comments (1)
src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsx (1)

299-305: Consider simplifying the nested ternary for readability.

The logic is correct but the nested ternary operators reduce readability. Consider extracting to a variable or simplifying the expression.

🔎 Suggested simplification:
-                  {compactButtons
-                    ? isEditingRow
-                      ? deleteButtonText
-                      : null
-                    : isEditingRow || !mobileViewSmall
-                      ? deleteButtonText
-                      : null}
+                  {(compactButtons ? isEditingRow : isEditingRow || !mobileViewSmall)
+                    ? deleteButtonText
+                    : null}

Or extract to a variable before the JSX:

const showDeleteText = compactButtons ? isEditingRow : (isEditingRow || !mobileViewSmall);
// ...
{showDeleteText ? deleteButtonText : null}
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5343591 and 7ff4853.

📒 Files selected for processing (2)
  • src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsx (8 hunks)
  • src/layout/RepeatingGroup/config.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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/RepeatingGroup/config.ts
  • src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.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/RepeatingGroup/config.ts
  • src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsx
src/layout/*/{config,Component,index,config.generated}.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Layout components must follow standardized structure with config.ts, Component.tsx, index.tsx, and config.generated.ts files

Files:

  • src/layout/RepeatingGroup/config.ts
🧬 Code graph analysis (1)
src/layout/RepeatingGroup/config.ts (1)
src/codegen/CG.ts (1)
  • CG (25-57)
⏰ 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: Analyze (javascript)
  • GitHub Check: Type-checks, eslint, unit tests and SonarCloud
  • GitHub Check: Install
🔇 Additional comments (4)
src/layout/RepeatingGroup/config.ts (1)

217-226: LGTM! Configuration property is well-defined and follows established patterns.

The compactButtons property is correctly placed under the edit config group as recommended in the PR discussion. The default value of false ensures this is an opt-in feature, avoiding breaking changes for existing service owners.

src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsx (3)

99-99: LGTM! Clean derivation of the configuration value.

Using Boolean() properly handles the optional property case, defaulting to false when compactButtons is undefined.


343-367: LGTM! EditElement properly implements the compact buttons logic.

The showText calculation correctly handles both modes:

  • When compactButtons is enabled: text appears only when the row is being edited (ariaExpanded)
  • When compactButtons is disabled: preserves original behavior (text shown when editing or on non-mobile views)

263-263: LGTM! Desktop delete button logic is clear and correct.

When compactButtons is enabled, text is shown only during editing; otherwise, text is always displayed.

Copy link
Contributor

@olemartinorg olemartinorg left a comment

Choose a reason for hiding this comment

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

Looks good!

@olemartinorg olemartinorg changed the title fix: Remove edit and delete buttons texts in view mode and show them in the edit one. feat: Config to remove edit and delete buttons texts in view mode and show them in the edit one. Dec 18, 2025
@olemartinorg olemartinorg added kind/product-feature Pull requests containing new features and removed kind/bug Something isn't working labels Dec 18, 2025
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: 0

🧹 Nitpick comments (3)
src/layout/RepeatingGroup/Table/RepeatingGroupTable.test.tsx (3)

210-210: Prefer semantic selector over CSS class dependency.

Using classList.contains('tableButton') couples the test to implementation details (CSS class names). Consider using a test ID or more semantic selector like a combination of role and accessible name.

🔎 View suggested refactor

Add a test ID to the table button in the component:

-const tableEditButton = editButtonsInEditMode.find((btn) => btn.classList.contains('tableButton'));
+const tableEditButton = screen.getByTestId('repeating-group-table-edit-button-0');

Alternatively, use a more specific query that doesn't rely on CSS classes:

-const tableEditButton = editButtonsInEditMode.find((btn) => btn.classList.contains('tableButton'));
+// Find the button that's within the table row at index 0
+const tableEditButton = screen.getAllByRole('button', { name: /Lagre og lukk/i })[0];

213-215: Clarify implicit test assumptions about button ordering.

The test assumes deleteButtons[0] is in edit mode (has text) and deleteButtons[1] is not (no text), but this isn't explicitly documented. Adding a comment would improve test readability.

🔎 View suggested improvement
+// In edit mode: first row's delete button should show text, others remain icon-only
 const deleteButtons = screen.getAllByRole('button', { name: /Slett/i });
 expect(deleteButtons[0]).toHaveTextContent('Slett');
 expect(deleteButtons[1]).not.toHaveTextContent('Slett');

175-217: Consider adding test coverage for default behavior.

The test suite validates compactButtons: true, but doesn't verify the default behavior when compactButtons is false or undefined. Adding a test case for the default would ensure backwards compatibility and clarify expected behavior.

🔎 View suggested test case
it('should show button text in both modes when compactButtons is false or not set', async () => {
  const groupWithoutCompactButtons = getFormLayoutRepeatingGroupMock({
    id: 'mock-container-id',
    edit: { compactButtons: false },
  });
  const layout = getLayout(groupWithoutCompactButtons, components);
  await render(layout);
  
  // In view mode, buttons should have text on desktop
  const editButtons = screen.getAllByRole('button', { name: /Rediger/i });
  const deleteButtons = screen.getAllByRole('button', { name: /Slett/i });
  expect(editButtons[0]).toHaveTextContent('Rediger');
  expect(deleteButtons[0]).toHaveTextContent('Slett');
});
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ff4853 and b6d4df5.

📒 Files selected for processing (2)
  • src/layout/RepeatingGroup/Table/RepeatingGroupTable.test.tsx (2 hunks)
  • src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsx (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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/RepeatingGroup/Table/RepeatingGroupTable.test.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/RepeatingGroup/Table/RepeatingGroupTable.test.tsx
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use renderWithProviders from src/test/renderWithProviders.tsx when testing components that require form layout context

Files:

  • src/layout/RepeatingGroup/Table/RepeatingGroupTable.test.tsx
🧠 Learnings (1)
📚 Learning: 2025-11-25T12:53:54.399Z
Learnt from: CR
Repo: Altinn/app-frontend-react PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T12:53:54.399Z
Learning: Applies to **/*.test.{ts,tsx} : Use `renderWithProviders` from `src/test/renderWithProviders.tsx` when testing components that require form layout context

Applied to files:

  • src/layout/RepeatingGroup/Table/RepeatingGroupTable.test.tsx
🧬 Code graph analysis (1)
src/layout/RepeatingGroup/Table/RepeatingGroupTable.test.tsx (2)
src/test/mockMediaQuery.tsx (1)
  • mockMediaQuery (3-25)
src/__mocks__/getFormLayoutGroupMock.ts (1)
  • getFormLayoutRepeatingGroupMock (4-15)
⏰ 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: Analyze (javascript)
  • GitHub Check: Type-checks, eslint, unit tests and SonarCloud
  • GitHub Check: Install
🔇 Additional comments (2)
src/layout/RepeatingGroup/Table/RepeatingGroupTable.test.tsx (2)

175-179: LGTM: Test setup follows existing patterns.

The test suite setup for compactButtons correctly mirrors the existing desktop view test configuration.


235-246: LGTM: Text resources properly added.

The new text resources correctly support the compactButtons test scenarios and maintain consistency with the existing Norwegian locale pattern.

@sonarqubecloud
Copy link

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/product-feature Pull requests containing new features squad/utforming Issues that belongs to the named squad.

Projects

Status: 🧪 Test

Development

Successfully merging this pull request may close these issues.

Mer kompakt visning av knappene Lagre og Slett

2 participants