From b9f8a6b6c08a41f10abeaa5b7143b74a493a6c79 Mon Sep 17 00:00:00 2001
From: Sage Abdullah <sage.abdullah@torchbox.com>
Date: Thu, 20 Apr 2023 13:55:15 +0700
Subject: [PATCH] Dispatch resize event to resize Handsontable on
 initialisation (#10367)

Fixes #10355
---
 CHANGELOG.txt                                       | 1 +
 client/src/entrypoints/contrib/table_block/table.js | 2 +-
 docs/releases/5.0.md                                | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index b701bb726b..e388cd678f 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -90,6 +90,7 @@ Changelog
  * Fix: When i18n is not enabled, avoid making a Locale query on every page view (Dan Braghis)
  * Fix: Fix initialisation of commenting widgets within StreamField (Thibaud Colas)
  * Fix: Fix various regressions in the commenting UI (Thibaud Colas)
+ * Fix: Prevent TableBlock from becoming uneditable after save (Sage Abdullah)
  * Docs: Add code block to make it easier to understand contribution docs (Suyash Singh)
  * Docs: Add new "Icons" page for icons customisation and reuse across the admin interface (Coen van der Kamp, Thibaud Colas)
  * Docs: Fix broken formatting for MultiFieldPanel / FieldRowPanel permission kwarg docs (Matt Westcott)
diff --git a/client/src/entrypoints/contrib/table_block/table.js b/client/src/entrypoints/contrib/table_block/table.js
index db8a4da972..c1c7676bcb 100644
--- a/client/src/entrypoints/contrib/table_block/table.js
+++ b/client/src/entrypoints/contrib/table_block/table.js
@@ -174,7 +174,7 @@ function initTable(id, tableOptions) {
     // Render the table. Calling render also removes 'null' literals from empty cells.
     hot.render();
     resizeHeight(getHeight());
-    resizeWidth(getWidth());
+    window.dispatchEvent(new Event('resize'));
   });
 }
 window.initTable = initTable;
diff --git a/docs/releases/5.0.md b/docs/releases/5.0.md
index 2c883e32d2..950e7a2059 100644
--- a/docs/releases/5.0.md
+++ b/docs/releases/5.0.md
@@ -145,6 +145,7 @@ We hope this new theme will bring accessibility improvements for users who perfe
  * When i18n is not enabled, avoid making a Locale query on every page view (Dan Braghis)
  * Fix initialisation of commenting widgets within StreamField (Thibaud Colas)
  * Fix various regressions in the commenting UI (Thibaud Colas)
+ * Prevent TableBlock from becoming uneditable after save (Sage Abdullah)
 
 ### Documentation