Skip to content

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

Open
Magnusrm wants to merge 1 commit into
mainfrom
fix/notify-screen-reader-when-deleting-row-in-rep-group
Open

Fix focus- and SR-issues in repeating group#4268
Magnusrm wants to merge 1 commit 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

  • New Features

    • Added screen reader announcements when rows are deleted from repeating groups, displaying updated row count.
    • Improved focus management for keyboard navigation: focus automatically moves to an actionable element after row deletion, and properly navigates during multi-page editing and save workflows.
  • Tests

    • Added accessibility tests verifying row deletion announcements and focus behavior in various edit scenarios.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds keyboard/accessibility focus management to RepeatingGroup components: a new ARIA live region announces row deletions 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 this.

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. Adds deletedRowsCount: number to the zustand Store, initialized to 0 and incremented on successful deletion in endDeletingRow.
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, extends refSetter with immediate-focus logic, and exports getRowToFocusAfterDeletion and useDeleteRowAndFocus.
Context actions returning Promise<boolean>
src/layout/RepeatingGroup/Providers/RepeatingGroupContext.tsx
Changes useOpenNextForEditing and useCloseForEditing to return Promise<boolean>, returning false when maybeValidateRow() blocks and true on success.
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 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.
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, validation-blocked saves, ARIA live region text on consecutive deletions, and post-deletion focus landing.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested labels

squad/utforming

🚥 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
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.
Title check ✅ Passed The title 'Fix focus- and SR-issues in repeating group' directly and accurately summarizes the main changes: accessibility improvements (focus management and screen reader announcements) for repeating groups.
Description check ✅ Passed The PR description is comprehensive and well-structured, following the template with clear sections for description, verification/QA, and acknowledgments of testing and labels.

✏️ 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/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
@sonarqubecloud

Copy link
Copy Markdown

@Magnusrm Magnusrm changed the title Fix focus and SR issues in repeating group Fix focus- and SR-issues in repeating group Jun 15, 2026
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/bug Something isn't working

Projects

Status: 🔎 In review

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

1 participant