From d58c9039eed19709e4a88aeacca243ebb061f01d Mon Sep 17 00:00:00 2001 From: Josh Oakes Date: Mon, 25 Nov 2024 14:23:21 -0600 Subject: [PATCH] Match column styles --- src/blocks/table/edit.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/blocks/table/edit.js b/src/blocks/table/edit.js index eff1593af..ae8a21d17 100644 --- a/src/blocks/table/edit.js +++ b/src/blocks/table/edit.js @@ -151,6 +151,15 @@ export function Edit(props) { } }, []); + const rowCount = select('core/block-editor').getBlocks(clientId); + + const adjustRows = (newRows) => { + if (newRows > rowCount.length) { + handleInsertRowBelow(9999); + } else { + handleDeleteLastRow(); + } + }; const updateColumnBackground = (index, color, isHover = false) => { const arrayToUpdate = isHover ? [...columnBackgroundsHover] : [...columnBackgrounds]; if (color === '') { @@ -194,7 +203,6 @@ export function Edit(props) { const handleInsertRowBelow = (index) => { const { insertBlock } = dispatch('core/block-editor'); const newRow = createTableRow(); - const blocks = select('core/block-editor').getBlocks(clientId); insertBlock(newRow, index + 1, clientId, false); }; @@ -360,14 +368,14 @@ export function Edit(props) { {activeTab === 'general' && ( <> - - - - + adjustRows(parseInt(value))} + min={1} + max={200} + style={{ marginTop: '15px' }} + />