From 2e61b74cb32d242b9fb9fbe9bb326ef5f2fb8102 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Fri, 22 Nov 2024 15:28:24 -0600 Subject: [PATCH] Paneset: check for existing id before registering pane --- lib/Paneset/Paneset.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Paneset/Paneset.js b/lib/Paneset/Paneset.js index c6c96e2cb..838dbbd75 100644 --- a/lib/Paneset/Paneset.js +++ b/lib/Paneset/Paneset.js @@ -442,10 +442,15 @@ class Paneset extends React.Component { this.interval = null; }); } else { - // insert sorted by left coordinate of clientrect... - const newPanes = insertByClientRect(newState.panes, paneObject); - newState = Object.assign(newState, { panes: newPanes, changeType: 'added' }); - // newState = this.insertPaneObject(newState, paneObject); + // check for duplicate id's before registering. Registration happens on mount. + // This will help with mount-twice strict mode strangeness + const paneExists = newState.panes.findIndex((p) => p.id === paneObject.id) + if (paneExists === -1) { + // insert sorted by left coordinate of clientrect... + const newPanes = insertByClientRect(newState.panes, paneObject); + newState = Object.assign(newState, { panes: newPanes, changeType: 'added' }); + // newState = this.insertPaneObject(newState, paneObject); + } } return newState; }, () => {