Skip to content

fix: remove extra edit button#4183

Merged
walldenfilippa merged 1 commit into
mainfrom
fix/18639-remove-extra-edit-button
May 8, 2026
Merged

fix: remove extra edit button#4183
walldenfilippa merged 1 commit into
mainfrom
fix/18639-remove-extra-edit-button

Conversation

@walldenfilippa
Copy link
Copy Markdown
Contributor

@walldenfilippa walldenfilippa commented May 8, 2026

Description

Removes the extra edit button.

The FileUploadComponents in the summary render an Edit button per row, as well as an Edit button in the header. It should only show the Edit button next to the header when no attachments exist. I have added an isEmpty condition to control the rendering of the header 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

  • Bug Fixes
    • Fixed Edit button visibility to display conditionally based on attachment status, appearing only when there are no filtered attachments.

@walldenfilippa walldenfilippa added kind/bug Something isn't working backport This PR should be cherry-picked onto older release branches squad/utforming Issues that belongs to the named squad. labels May 8, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

AttachmentSummaryComponent2 now conditionally renders the EditButton component based on the isEmpty state. The button appears only when no filtered attachments exist, replacing the previous unconditional rendering behavior.

Changes

EditButton Conditional Rendering

Layer / File(s) Summary
Conditional Rendering Logic
src/layout/FileUpload/AttachmentSummaryComponent2.tsx
EditButton rendering is wrapped in a conditional check and now appears only when isEmpty === true.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: remove extra edit button' directly and clearly describes the main change in the PR, which involves conditionally hiding the header Edit button.
Description check ✅ Passed The PR description provides a detailed explanation of the changes, includes the related issue, and comprehensively addresses all major verification/QA checklist items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/18639-remove-extra-edit-button

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.

@walldenfilippa walldenfilippa changed the title remove extra edit button fix: remove extra edit button May 8, 2026
Copy link
Copy Markdown
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/FileUpload/AttachmentSummaryComponent2.tsx (1)

62-67: 💤 Low value

Reuse the already-computed isEmpty at line 69.

Line 69 repeats filteredAttachments.length === 0 while isEmpty (defined at line 37) already captures the same expression. Consider using it for consistency.

♻️ Proposed refactor
-      {filteredAttachments.length === 0 ? (
+      {isEmpty ? (

Also applies to: 69-69

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/layout/FileUpload/AttachmentSummaryComponent2.tsx` around lines 62 - 67,
The code repeats the same emptiness check; replace the direct expression
filteredAttachments.length === 0 with the already-computed isEmpty boolean to
keep consistency and avoid duplicate logic. Locate the conditional in
AttachmentSummaryComponent2 where filteredAttachments.length === 0 is used and
change it to use isEmpty, keeping the surrounding JSX (e.g., the EditButton with
className={classes.summaryEditButton} and
targetBaseComponentId={targetBaseComponentId}) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/layout/FileUpload/AttachmentSummaryComponent2.tsx`:
- Around line 62-67: The code repeats the same emptiness check; replace the
direct expression filteredAttachments.length === 0 with the already-computed
isEmpty boolean to keep consistency and avoid duplicate logic. Locate the
conditional in AttachmentSummaryComponent2 where filteredAttachments.length ===
0 is used and change it to use isEmpty, keeping the surrounding JSX (e.g., the
EditButton with className={classes.summaryEditButton} and
targetBaseComponentId={targetBaseComponentId}) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb852a63-15d6-45af-87e3-a78160853a12

📥 Commits

Reviewing files that changed from the base of the PR and between bce9f48 and 1abd53b.

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

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

@JamalAlabdullah JamalAlabdullah left a comment

Choose a reason for hiding this comment

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

Tested and works nice 👍 , you can merge when all test are green

@walldenfilippa walldenfilippa merged commit d3938e9 into main May 8, 2026
19 checks passed
@walldenfilippa walldenfilippa deleted the fix/18639-remove-extra-edit-button branch May 8, 2026 08:35
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Automatic backport successful!

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

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

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

walldenfilippa added a commit that referenced this pull request May 13, 2026
Co-authored-by: walldenfilippa <filippa.walden@digdir.no>
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

None yet

Development

Successfully merging this pull request may close these issues.

An extra Edit button has appeared in the summary component

2 participants