Skip to content

Commit

Permalink
Paneset: check for existing id before registering pane
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnC-80 committed Nov 22, 2024
1 parent a3e41cd commit 2e61b74
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/Paneset/Paneset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, () => {
Expand Down

0 comments on commit 2e61b74

Please sign in to comment.