Skip to content

Commit 1758545

Browse files
authored
Forms: Fix dashboard initialization (#45539)
* Forms: Use data attribute to track initialization state * Add changelog
1 parent bf1d20a commit 1758545

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: changed
3+
4+
Forms: Make dashboard initialization idempotent for SPA environments by using data attribute to track state

projects/packages/forms/src/dashboard/index.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,17 @@ declare global {
2121
}
2222
}
2323

24-
let isInitialized = false;
25-
2624
/**
2725
* Initialize the Forms dashboard
2826
*/
2927
function initFormsDashboard() {
30-
if ( isInitialized ) {
31-
return;
32-
}
33-
3428
const container = document.getElementById( 'jp-forms-dashboard' );
3529

36-
if ( ! container ) {
30+
if ( ! container || container.dataset.formsInitialized ) {
3731
return;
3832
}
3933

40-
isInitialized = true;
34+
container.dataset.formsInitialized = 'true';
4135

4236
const router = createHashRouter( [
4337
{

0 commit comments

Comments
 (0)