Skip to content

fix: fixed the hiding edit button in summery2#4059

Merged
JamalAlabdullah merged 5 commits intomainfrom
18113-show-edit-button-i-summery2
Mar 16, 2026
Merged

fix: fixed the hiding edit button in summery2#4059
JamalAlabdullah merged 5 commits intomainfrom
18113-show-edit-button-i-summery2

Conversation

@JamalAlabdullah
Copy link
Contributor

@JamalAlabdullah JamalAlabdullah commented Mar 12, 2026

Description

Before image
After fixed-edit-button

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 an edit button to the file attachment summary header for quick in-place editing.
  • Style

    • Improved attachment summary header layout, alignment, and edit-button sizing.
  • Tests

    • Added tests for nested-child editing/navigation in repeating groups and updated end-to-end expectations for additional edit controls.
  • Refactor

    • Internal logic reworked to more reliably collect editable child components (no public API changes).

@JamalAlabdullah JamalAlabdullah added kind/bug Something isn't working backport This PR should be cherry-picked onto older release branches labels Mar 12, 2026
@JamalAlabdullah JamalAlabdullah linked an issue Mar 12, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds an EditButton to attachment summary headers with new CSS classes; refactors repeating-group child discovery to recursively collect editable form children; updates unit and e2e tests for nested repeating-group child navigation and adjusted Endre button counts.

Changes

Cohort / File(s) Summary
Attachment Summary UI
src/layout/FileUpload/AttachmentSummaryComponent2.tsx, src/layout/FileUpload/FileUploadTable/FileTableComponent.module.css
Imported and rendered EditButton in the attachment summary header; replaced standalone label with a header container and added .summaryHeader and .summaryEditButton CSS selectors for alignment.
Repeating Group Utilities
src/layout/RepeatingGroup/utils.ts
Renamed internal helper isChildEditableCheckisEditableFormComponent; added collectEditableChildren to recursively gather editable form child IDs; updated useEditableChildren to include nested editable children.
Repeating Group Tests
src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.test.tsx
Added a layout with a nested group child and a test verifying navigation targets when editing nested repeating-group children.
E2E Test Expectation
test/e2e/integration/component-library/repeating-group.ts
Updated two expectations to reflect increased count of "Endre" buttons (from 13 to 16).
Selector Traversal in E2E
test/e2e/integration/subform-test/subform.ts
Replaced .next() traversals with .parent().parent() in three assertions to target an ancestor container before checking text.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 The PR description lacks a non-technical summary of changes. Only before/after images are provided without describing what was actually changed. Add a clear description of what was fixed (e.g., 'Fixed edit button visibility and positioning in Summary2 component by restructuring the header layout and adding CSS styling'), then check the appropriate verification/QA boxes to indicate what testing was performed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title mentions fixing the hidden edit button in 'summery2' which aligns with the core changes made to the AttachmentSummaryComponent2 to add and properly display the EditButton.

✏️ 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 18113-show-edit-button-i-summery2
📝 Coding Plan for PR comments
  • Generate coding plan

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.

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/RepeatingGroup/utils.ts (1)

106-109: Remove the container as cast here.

Line 107 introduces a new unchecked cast in the traversal path. Prefer a type guard on childComponent/children so this stays type-safe and future container shape changes fail at compile time instead of silently at runtime.

♻️ Suggested cleanup
-  if (componentDef.category === CompCategory.Container) {
-    const containerChildren = (childComponent as { children?: string[] }).children ?? [];
+  if (componentDef.category === CompCategory.Container) {
+    const containerChildren =
+      'children' in childComponent && Array.isArray(childComponent.children) ? childComponent.children : [];
     for (const grandChildId of containerChildren) {
       collectEditableChildren(grandChildId, layoutLookups, parentComponent, rowWithExpressions, acc);
     }
     return;
   }

As per coding guidelines, "Avoid using any or type casting (as type) in TypeScript; instead, improve typing by removing such casts and anys to maintain proper type safety".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/layout/RepeatingGroup/utils.ts` around lines 106 - 109, The code uses an
unchecked cast on childComponent to access children inside the
CompCategory.Container branch; instead add a type guard to assert the shape
(e.g., check 'children' in childComponent &&
Array.isArray(childComponent.children')) before iterating so the cast is
removed—update the block guarded by componentDef.category ===
CompCategory.Container to retrieve containerChildren only when the guard passes
and then call collectEditableChildren(grandChildId, layoutLookups,
parentComponent, rowWithExpressions, acc) for each grandChildId; this keeps
typesafe access to childComponent.children and eliminates the as-cast.
🤖 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/RepeatingGroup/utils.ts`:
- Around line 106-109: The code uses an unchecked cast on childComponent to
access children inside the CompCategory.Container branch; instead add a type
guard to assert the shape (e.g., check 'children' in childComponent &&
Array.isArray(childComponent.children')) before iterating so the cast is
removed—update the block guarded by componentDef.category ===
CompCategory.Container to retrieve containerChildren only when the guard passes
and then call collectEditableChildren(grandChildId, layoutLookups,
parentComponent, rowWithExpressions, acc) for each grandChildId; this keeps
typesafe access to childComponent.children and eliminates the as-cast.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c98bff95-5e69-4045-8418-3d9519a2dc51

📥 Commits

Reviewing files that changed from the base of the PR and between e899e6d and 70daa45.

📒 Files selected for processing (3)
  • src/layout/FileUpload/AttachmentSummaryComponent2.tsx
  • src/layout/FileUpload/FileUploadTable/FileTableComponent.module.css
  • src/layout/RepeatingGroup/utils.ts

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.test.tsx`:
- Around line 222-233: The test currently asserts the fallback navigation target
("repeating-group") after clicking the edit button; update it to assert the
nested child target instead: use the same setup (render with
layoutWithNestedGroupChild and clicking the editButton) but change the
expectation on the navigate mock to verify navigation to the nested child id
(the `nested-input` target referenced by `tableHeaders` / collected by
`collectEditableChildren`) — i.e., replace the
expect(navigate).toHaveBeenCalledWith('repeating-group', 'repeating-group', ...)
assertion with an assertion that the second argument is the nested child id
(e.g. 'nested-input') while keeping expect.any(Object) for the options.
- Line 12: Remove the double type cast on the `inner-group` fixture: locate the
fixture named "inner-group" (used in RepeatingGroupTableSummary tests) and
delete the trailing `as unknown as CompInternal` so the fixture is left as its
concrete Group object type; keep the import of CompInternal if still used
elsewhere but do not cast the fixture—this matches the pattern used in
SummaryGroupComponent.test.tsx and Form.test.tsx and preserves type safety.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 868701db-5fbf-4d68-a2bd-22fa4210601e

📥 Commits

Reviewing files that changed from the base of the PR and between 70daa45 and 7ee27cd.

📒 Files selected for processing (1)
  • src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.test.tsx

@sonarqubecloud
Copy link

@JamalAlabdullah JamalAlabdullah added the squad/utforming Issues that belongs to the named squad. label Mar 12, 2026
@JamalAlabdullah JamalAlabdullah moved this to 🔎 In review in Team Altinn Studio Mar 12, 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.

Good job! 💯 I am curious why the added styling in FileTableComponent is necessary, other than that approved and you can merge this if you have tested this well when it should be displayed and when it shouldn't be displayed. 🙂 I have tested a little, where the edit button is displayed and one case where it is hidden when readOnly is added, and it works as expected 👍

Edit: you can you deploy this to production when it is merged by using backport as labeled.

@JamalAlabdullah
Copy link
Contributor Author

Good job! 💯 I am curious why the added styling in FileTableComponent is necessary, other than that approved and you can merge this if you have tested this well when it should be displayed and when it shouldn't be displayed. 🙂 I have tested a little, where the edit button is displayed and one case where it is hidden when readOnly is added, and it works as expected 👍

Edit: you can you deploy this to production when it is merged by using backport as labeled.

I added styling because the edit button was not in this part( see picture ), I added the button explicitly and the hover and placement was not as other buttons , thats why i added the style.
Screenshot 2026-03-16 at 11 35 27

@JamalAlabdullah JamalAlabdullah merged commit a7a2bef into main Mar 16, 2026
17 checks passed
@JamalAlabdullah JamalAlabdullah deleted the 18113-show-edit-button-i-summery2 branch March 16, 2026 11:14
@github-project-automation github-project-automation bot moved this from 🔎 In review to ✅ Done in Team Altinn Studio Mar 16, 2026
github-actions bot pushed a commit that referenced this pull request Mar 16, 2026
* fix: fixed the hiding edit button in summery2

* added test

* test

* test

* test
@github-actions
Copy link
Contributor

Automatic backport successful!

A backport PR has been automatically created for the release/v4.26 release branch.

The release branch release/v4.26 already existed and was updated.

The cherry-pick was clean with no conflicts. Please review the backport PR when it appears.

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 squad/utforming Issues that belongs to the named squad.

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

show change button i summery2

2 participants