Skip to content

Fix focus- and SR-issues in repeating group#4268

Merged
Magnusrm merged 3 commits into
mainfrom
fix/notify-screen-reader-when-deleting-row-in-rep-group
Jun 23, 2026
Merged

Fix focus- and SR-issues in repeating group#4268
Magnusrm merged 3 commits into
mainfrom
fix/notify-screen-reader-when-deleting-row-in-rep-group

Conversation

@Magnusrm

@Magnusrm Magnusrm commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

  • Screen reader not notified when a row is deleted
    • Added a visually-hidden aria-live status region driven by a deletedRowsCount counter at the single endDeletingRow choke point, covering both delete entry points.
  • Focus fell to the page body after deletion (page title read, preempting the announcement)
    • Focus now moves to the previous row (race-free), or the Add button when no rows remain; registered the table row as a focus target for read-only tables.
  • multiPage navigation left focus on the Next/Back button
    • Focus now moves to the top (first field) of the edit container in both directions.
  • Save & Close focus target
    • Now returns focus to the same row's edit button instead of the next row's.
  • Save & Open Next focus target
    • Now moves focus to the first field of the next row's edit container instead of the next row's edit button.

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

Summary by CodeRabbit

  • New Features

    • Added screen reader announcements for repeating-group row deletions, including updated remaining-row counts.
    • Enhanced keyboard focus management for multi-page editing and save flows, restoring focus to the appropriate edit controls and advancing focus after “save and next/close.”
    • Updated localized screen-reader text for row-deletion status in English, Bokmål, and Nynorsk.
  • Tests

    • Added/extended accessibility tests covering live-region updates and focus movement across consecutive deletions and edit navigation scenarios.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Magnusrm, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 50 minutes and 39 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c54ece69-32b0-4ea2-bfcd-80f47348642a

📥 Commits

Reviewing files that changed from the base of the PR and between 15e819d and 9101d57.

📒 Files selected for processing (3)
  • src/layout/RepeatingGroup/Container/RepeatingGroupContainer.tsx
  • src/layout/RepeatingGroup/EditContainer/RepeatingGroupsEditContainer.tsx
  • src/layout/RepeatingGroup/Providers/RepeatingGroupFocusContext.tsx
📝 Walkthrough

Walkthrough

Adds keyboard and accessibility focus management to RepeatingGroup components: a new ARIA live region announces row deletions with updated row counts using new i18n strings, and focus moves correctly after delete, multi-page navigation, save-and-close, and save-and-next actions. The focus context, zustand store, and edit/table row components are all updated to support these transitions.

Changes

RepeatingGroup accessibility: focus management and ARIA live region

Layer / File(s) Summary
i18n strings and deletedRowsCount state
src/language/texts/en.ts, src/language/texts/nb.ts, src/language/texts/nn.ts, src/layout/RepeatingGroup/Providers/RepeatingGroupContext.tsx
Adds group.row_deleted_sr translation key in all three locales with {0} placeholder for remaining row count. Adds deletedRowsCount: number to the zustand Store, initialized to 0 and incremented on successful deletion in endDeletingRow. Changes useOpenNextForEditing and useCloseForEditing to return Promise<boolean>, returning false when maybeValidateRow() blocks and true on success.
Focus context expansion and deletion helpers
src/layout/RepeatingGroup/Providers/RepeatingGroupFocusContext.tsx
Adds focus-target key constants, new context methods (focusEditContainer, focusEditButton, registerAddButton, focusAddButton), reworks triggerFocus to prioritize specific sub-elements over row-container fallback, extends refSetter with immediate-focus logic for registered edit elements, and exports getRowToFocusAfterDeletion and useDeleteRowAndFocus.
ARIA live region and AddButton focus registration
src/layout/RepeatingGroup/Container/RepeatingGroupContainer.tsx
Introduces RowDeletionAnnouncement, a visually-hidden aria-live="polite" component that emits a localized message when deletedRowsCount increases. AddButton registers itself via registerAddButton ref and removes the duplicate onKeyUp keyboard handler.
Table row focus ref wiring
src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsx
Switches deleteRow to useDeleteRowAndFocus, attaches refSetter to Table.Row, and passes buttonRef into EditElement across all three render paths (vertical, horizontal, mobile). EditElement forwards the optional buttonRef to its Button.
Edit container focus wiring
src/layout/RepeatingGroup/EditContainer/RepeatingGroupsEditContainer.tsx
Multi-page prev/next buttons schedule focusEditContainer via requestAnimationFrame. "Save and next" awaits openNextForEditing() and focuses the next container or falls back to the edit button. "Save and close" awaits closeForEditing() and schedules focus back to the row's edit button. Context destructuring expanded to include focusEditContainer and focusEditButton.
Container tests for focus and live region
src/layout/RepeatingGroup/Container/RepeatingGroupContainer.test.tsx
Wraps the render helper with RepeatingGroupsFocusProvider and adds tests for multi-page focus navigation, save-and-close/next focus outcomes, validation-blocked focus retention, ARIA live region text on consecutive deletions, and post-deletion focus landing on actionable elements.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Suggested labels

area/accessibility

Suggested reviewers

  • adamhaeger
🚥 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 clearly and concisely summarizes the main changes: fixing focus management and screen reader announcement issues in repeating group components.
Description check ✅ Passed The description covers all key aspects of the changes with clear explanations of what was fixed, verification/QA checkboxes are properly completed, and the PR follows the template structure with detailed problem-solution pairs.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/notify-screen-reader-when-deleting-row-in-rep-group

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.

@Magnusrm Magnusrm added kind/bug Something isn't working backport-ignore This PR is a new feature and should not be cherry-picked onto release branches labels Jun 15, 2026
@Magnusrm Magnusrm moved this to 🔎 In review in Team Altinn Studio Jun 15, 2026
@Magnusrm Magnusrm marked this pull request as ready for review June 15, 2026 07:48
@Magnusrm Magnusrm changed the title Fix focus and SR issues in repeating group Fix focus- and SR-issues in repeating group Jun 15, 2026
@adamhaeger adamhaeger self-requested a review June 18, 2026 10:54
Comment thread src/layout/RepeatingGroup/Container/RepeatingGroupContainer.tsx Outdated

@adamhaeger adamhaeger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested and works well! Code also look good, but maybe consider if we need all the comments or if they can be worded a bit simpler?

@sonarqubecloud

Copy link
Copy Markdown

@Magnusrm Magnusrm merged commit 6a68b73 into main Jun 23, 2026
15 of 16 checks passed
@Magnusrm Magnusrm deleted the fix/notify-screen-reader-when-deleting-row-in-rep-group branch June 23, 2026 08:52
@github-project-automation github-project-automation Bot moved this from 🔎 In review to ✅ Done in Team Altinn Studio Jun 23, 2026
@Magnusrm Magnusrm added backport This PR should be cherry-picked onto older release branches and removed backport-ignore This PR is a new feature and should not be cherry-picked onto release branches labels Jun 23, 2026
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: ✅ Done

Development

Successfully merging this pull request may close these issues.

WCAG-brudd: 2.4.3 Fokusrekkefølgje (Nivå A) Tab order is wrong in repeating group v2 WCAG-brudd: 4.1.3 Statusbeskjeder (AA): repeating group

2 participants