bugfix(core): prevent infinite render loop for array/object control v…#129
Merged
Conversation
…alues hasControlsChanged compared a control's `value` by reference (`!==`), so any control whose value is an array or object (e.g. multiselect) was reported as changed on every render, re-registering the section each time. Since v2.5 the store's setState uses deepEqual (which no longer drops onChange handlers), each redundant re-registration became a real store mutation, and the registration effect depends on `sections` — closing the loop into "Maximum update depth exceeded". Compare control values structurally with deepEqual instead, and also deep-compare multiselect `options`. Adds regression tests for multiselect.
🦋 Changeset detectedLatest commit: afc55bc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Description
What does this PR do?
Fixes an infinite render loop (
Maximum update depth exceeded) that appeared in v2.5 for any control whosevalueis an array or object — in practice, themultiselectcontrol.Root cause (two pieces):
hasControlsChangedcompared a control'svalueby reference (!==). A control with an array/objectvalue(likemultiselect, whose value consumers typically rebuild each render via.map(...)) was reported as changed on every render, soregisterSectionfired every render.setStatecomparison fromJSON.stringifytodeepEqual(commitb5f762b).deepEqualcompares functions by reference, and the hook re-wrapsonChangeofpersistcontrols into new functions on every render — so each redundant re-registration became a real store mutation. Since the registration effect depends onsections, the store update re-triggered the effect → infinite loop.Before v2.5 this never closed the loop because
JSON.stringifydropped functions and compared array content, making redundant re-registrations no-ops.Fix: compare control
valuestructurally withdeepEqual(already imported), and deep-comparemultiselectoptionsas well. Adds regression tests and apatchchangeset.🎯 Type of change
🏗️ Affected areas
src/hooks,src/managers) -useDevPanel, auto-mount, manager*.spec.ts)🔗 Related links
Release
npm run changeset) for consumer-facing changesKey points to review
hasControlsChanged: value comparison moved from!==todeepEqual. This is also more correct generally —multiselectoptionspreviously had no comparison branch, so option changes went undetected.multiselectis the only one with an array/objectvalue; all others (boolean,string,number) are primitives. The fix is generic, so future controls with array/object values are covered automatically.Changes requiring special attention
BaseStoreService.setState'sdeepEqual(which detects handler-only changes) is left as-is; this PR breaks the loop at thehasControlsChangedlayer. No change to store semantics.Additional setup required