Skip to content

fix(shell): keep parentAlertsAdd stable across host prop updates - #968

Open
HendrikThePendric wants to merge 1 commit into
masterfrom
fix/stable-parent-alerts-add
Open

HendrikThePendric wants to merge 1 commit into
masterfrom
fix/stable-parent-alerts-add

Conversation

@HendrikThePendric

@HendrikThePendric HendrikThePendric commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Inside a plugin, PluginLoader passed AppAdapter a new parentAlertsAdd every time the host updated the plugin's props. That changed the identity of app-runtime's useAlert().show, so plugin effects and callbacks that depend on show re-ran on every host update.

PluginLoader now keeps the latest alertsAdd from the host in a ref and passes one function that never changes. That function calls the latest alertsAdd and returns its result.

Adds PluginLoader tests that use the real post-robot, with the test acting as the host window. jsdom's postMessage is patched to set event.source and event.origin, which post-robot needs. @dhis2/app-adapter is mocked.

Possible follow-ups: onPluginError, clearPluginError, resizePluginHeight and resizePluginWidth are also replaced with new functions on every host message. For the resize callbacks, this recreates the ResizeObserver each time.

🤖 Generated with Claude Code

receivePropsFromParent stored a new alertsAdd wrapper on every message
from the host, and post-robot gives a new proxy on every message too.
So every prop change on the host gave AppAdapter a new parentAlertsAdd,
which changed the identity of useAlert's `show` inside plugins.

Keep the latest alertsAdd in a ref and pass one stable function that
calls it and returns its result.

Add tests that use the real post-robot, with the test acting as the
host window, and mock @dhis2/app-adapter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HendrikThePendric
HendrikThePendric force-pushed the fix/stable-parent-alerts-add branch from 393f8db to b07861c Compare November 10, 2026 10:40
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

1 participant