From c9bb72d14d435240dafa21e610683fb8763fd408 Mon Sep 17 00:00:00 2001 From: Timothy Mugo Date: Mon, 9 Nov 2026 12:59:26 +0300 Subject: [PATCH] fix(timeline): improve per-point configuration handling for post count --- .../blocks/new-time-line/BlockEdit.js | 10 ++++++---- .../blocks/time-line/BlockEdit.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/wp-react-blocks-plugin/blocks/new-time-line/BlockEdit.js b/plugins/wp-react-blocks-plugin/blocks/new-time-line/BlockEdit.js index a874b391..3cdd0dd9 100644 --- a/plugins/wp-react-blocks-plugin/blocks/new-time-line/BlockEdit.js +++ b/plugins/wp-react-blocks-plugin/blocks/new-time-line/BlockEdit.js @@ -38,14 +38,16 @@ const FontSelector = (props) => { } /** - * Builds the per-point configuration for `count` points, keeping any existing - * entries and creating defaults for the new ones. Used both for rendering and - * when the number of posts changes, so the saved config always matches `count`. + * Builds the per-point configuration. Existing entries are always kept as they + * are, even beyond `count`, so lowering the number of posts (or passing through + * a lower value while typing it) never discards saved settings. Default entries + * are only created for points that have no saved entry yet. */ const buildConfig = (config, count) => { const current = Array.isArray(config) ? config : [] const result = [] - for (let i = 0; i < (count || 0); i++) { + const total = Math.max(count || 0, current.length) + for (let i = 0; i < total; i++) { if (!current[i]) { result.push({ circleColor: COLORS[i] || "#000000", diff --git a/plugins/wp-react-blocks-plugin/blocks/time-line/BlockEdit.js b/plugins/wp-react-blocks-plugin/blocks/time-line/BlockEdit.js index 98469edb..8192245b 100644 --- a/plugins/wp-react-blocks-plugin/blocks/time-line/BlockEdit.js +++ b/plugins/wp-react-blocks-plugin/blocks/time-line/BlockEdit.js @@ -38,14 +38,16 @@ const FontSelector = (props) => { } /** - * Builds the per-point configuration for `count` points, keeping any existing - * entries and creating defaults for the new ones. Used both for rendering and - * when the number of posts changes, so the saved config always matches `count`. + * Builds the per-point configuration. Existing entries are always kept as they + * are, even beyond `count`, so lowering the number of posts (or passing through + * a lower value while typing it) never discards saved settings. Default entries + * are only created for points that have no saved entry yet. */ const buildConfig = (config, count) => { const current = Array.isArray(config) ? config : [] const result = [] - for (let i = 0; i < (count || 0); i++) { + const total = Math.max(count || 0, current.length) + for (let i = 0; i < total; i++) { if (!current[i]) { result.push({ circleColor: COLORS[i] || "#000000",