Skip to content

Fix DataTable bulk actions observer recreation - #8834

Open
harshita-jangra wants to merge 1 commit into
primer:mainfrom
harshita-jangra:fix/issue-8715-mutation-observer
Open

harshita-jangra wants to merge 1 commit into
primer:mainfrom
harshita-jangra:fix/issue-8715-mutation-observer

Conversation

@harshita-jangra

Copy link
Copy Markdown

Closes #8715

Overview

Fixes the unnecessary recreation of a MutationObserver on document.body during every render of TableBulkActions.

The observer is now managed separately from the render lifecycle, avoiding unnecessary observer recreation while preserving focus recovery behavior.

The latest onFocusReturn callback is maintained using a ref to ensure the current callback is used when focus recovery occurs.

Added a regression test to verify that rerendering does not recreate the focus observer.

Changelog

New

  • Added a regression test to prevent unnecessary focus observer recreation on rerender.

Changed

  • Updated the focus observer lifecycle in TableBulkActions.
  • Kept the latest onFocusReturn callback available through a ref.

Removed

  • None.

Rollout strategy

  • No changes needed in github/github-ui
  • Needs changes in github/github-ui
  • Ships with feature flag(s)
  • Not sure
  • No rollout required — This is an internal implementation change with no public API changes.

Testing & Reviewing

  • Ran the DataTableBulkActions test suite.
  • All 23 tests passed.
  • Added a regression test to verify that the observer is not recreated when the component rerenders.

@harshita-jangra
harshita-jangra requested a review from a team as a code owner November 24, 2026 15:06
@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f8b10db

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

This branch was successfully deployed

1 active deployment
github-pages — f8b10dbe Deployed Nov 24, 2026 by harshita-jangra via deploy-preview #30840
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataTable: TableBulkActions re-creates a MutationObserver on document.body every render

1 participant