Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid sending props twice when using View as and plugin changes #2248

Merged
merged 1 commit into from
Mar 16, 2023

Conversation

edoardo
Copy link
Member

@edoardo edoardo commented Mar 16, 2023

I discovered this problem when testing the "View as" feature in dashboard.

The problem was that props where sent twice to the plugin and I think some of the postRobot timeout errors where a consequence of that.

This is what happened.
When using "View as" and switching app, ie. from DV to Maps and viceversa, the plugin loaded in the iframe needs to change.
This causes the "new" plugin to send the getProps message to dashboard, but at the same time pluginProp in dashboard IframePlugin component changes (the visualization object is adapted for DV/Maps) which causes newProps message to be sent from dashboard to the plugin.
The props are then sent twice, which would cause a re-render of the plugin.
I also suspect some of the postRobot console errors are due to newProps being sent while the listener in the plugin is not yet available.

This refactor uses the same approach used in the "future" component in app-runtime, currently in the alpha branch:
https://github.com/dhis2/app-runtime/blob/alpha/services/plugin/src/Plugin.tsx

@dhis2-bot
Copy link
Contributor

🚀 Deployed on https://pr-2248--dhis2-dashboard.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify March 16, 2023 16:09 Inactive
@edoardo edoardo merged commit be17d00 into master Mar 16, 2023
@edoardo edoardo deleted the fix/postRobot-communication branch March 16, 2023 17:23
dhis2-bot added a commit that referenced this pull request Mar 16, 2023
## [99.10.18](v99.10.17...v99.10.18) (2023-03-16)

### Bug Fixes

* avoid sending props twice when using View as and plugin changes ([#2248](#2248)) ([be17d00](be17d00))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 99.10.18 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

jenniferarnesen added a commit that referenced this pull request Mar 22, 2023
…v40] (#2266)

* fix: unwanted re-rendering of dashboard items (#2247)

* fix: solve most unwanted re-renders of dashboard items

This is basically reverting a change I added to solve a DV Highchart's
cutoff issue.
I think I found another approach for that issue which does not require
to pass style to the plugin, which is a problem because of course it
changes any time the dashboard item container changes size (window
resize, resize of other dashboard items, interpretation panel toggle,
etc...).

* chore: bump cli-app-scripts to solve no-service-worker issue

* fix: avoid sending props twice when using View as and plugin changes (#2248)

* fix: use chrome in e2e tests

---------

Co-authored-by: Edoardo Sabadelli <[email protected]>
jenniferarnesen added a commit that referenced this pull request Mar 23, 2023
…ch/2.40.0] (#2267)

* fix: unwanted re-rendering of dashboard items (#2247)

* fix: solve most unwanted re-renders of dashboard items

This is basically reverting a change I added to solve a DV Highchart's
cutoff issue.
I think I found another approach for that issue which does not require
to pass style to the plugin, which is a problem because of course it
changes any time the dashboard item container changes size (window
resize, resize of other dashboard items, interpretation panel toggle,
etc...).

* chore: bump cli-app-scripts to solve no-service-worker issue

* fix: avoid sending props twice when using View as and plugin changes (#2248)

---------

Co-authored-by: Edoardo Sabadelli <[email protected]>
Co-authored-by: Jan Henrik Øverland <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants