Feat/new data entry app compatibility fixes#174
Conversation
BundleMonNo change in files bundle size Groups updated (1)
Final result: ✅ View report in BundleMon website ➡️ |
MatiasArriola
left a comment
There was a problem hiding this comment.
Thanks @deeonwuli! Nice to see the integration with the new app. Please check my comments inline.
| currentOrganisationUnitId: Id; | ||
| currentDataSetId: Id; | ||
| getSelectedPeriod(): Maybe<Period>; | ||
| currentPeriodId: Id; |
There was a problem hiding this comment.
It is worth declaring this currentPeriodId prop as optional to better reflect the types in reality. Also consider adding a simple comment stating the prop is v42+ only, and getSelectedPeriod is for < 42.
| function removeJSDisabledMessage() { | ||
| const root = document.getElementById("root"); | ||
| if (root?.parentNode) { | ||
| Array.from(root.parentNode.childNodes).forEach(node => { | ||
| if ( | ||
| node.nodeType === Node.TEXT_NODE && | ||
| node.textContent?.includes(i18n.t("You need to enable JavaScript")) | ||
| ) { | ||
| node.remove(); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Interesting! I assume the new data entry app started rendering the noscript tag from index.html.
I would consider some alternative for this implementation. It is fine as a workaround, but let's check if there is a better solution. This adds an extra unnecessary translation key, because at this point i18n is not initialized.
If this is the <noscript> tag from index.html, we could:
- try adding an id to the noscript element and remove it by its id instead of scanning nodes
document.getElementById("js-disabled-message")?.remove() - or keep current approach, just define the seach text as a constant, remove the i18n call, and remove it from translation files
I would remove the noscript tag entirely, but since this app has other variants like the configurator we might want to keep it.
There was a problem hiding this comment.
Good catch on the i18n call — you're right, it's not initialized at that point.
I went with the second approach: the search text is now a plain string constant ("You need to enable JavaScript"), the i18n.t() call has been removed, and the translation key has been removed from all .po/.pot files.
I also tried the getElementById approach first, but it doesn't work here — the text node comes from the host Data Entry app's HTML (DHIS2 v42+), not from our index.html. So our is never present in the deployed context. We match by text content since the host element has no id.
…alization strings
…app compatibility
MatiasArriola
left a comment
There was a problem hiding this comment.
Nice, thanks @deeonwuli!!
|
Hi @deeonwuli I checked the new form by using the TUB Annual data as a test and found some things to fix:
|
|
Hello, I'm leaving some comments regarding the second part of this PR:
|
|
@deeonwuli you can go ahead and apply these changes @MatiasArriola suggested whenever you have a moment. You can reopen the PR if you want or create a new one, whatever is easiest for you. If you create a new one please link this one there. Thanks! EDIT: I see it is already here: |


📌 References
📝 Implementation
useDataEntrySelector, the period is now read fromdhis2.de.currentPeriodIdfirst (falling back todhis2.de.getSelectedPeriod()?.iso). This adds compatibility with the new DHIS2 Data Entry app which exposescurrentPeriodIdinstead of relying solely ongetSelectedPeriod().removeJSDisabledMessage()inindex.tsxthat strips the -style text node from the host app's DOM when the React app initializes inside the DHIS2 Data Entry app.IframeEscapePortalthat portals children into the topmost same-origin document and re-points `styled-components' StyleSheetManager and MUI v4's JSS provider at that document. Without the re-point, the portalled nodes would render unstyledsection.styles.columns.backgroundColorcan be an rgba() value, which blends with whatever sits behind theth. That backdrop is white in the legacy app but a different color inside the new app's iframe, so the same config produced visibly different header colors. Painted the configured color as a linear-gradient over a solid white background-color on the th itself, so the result no longer depends on the host background. Solid colors are unaffected.🎨 Screenshots
Screen.Recording.2026-04-07.at.11.03.31.mov
🔥 Notes to the tester
#869cn5qjz