fix(splitter): re-initialize panels when child count changes dynamically#8478
Open
YevheniiKotyrlo wants to merge 1 commit intoprimefaces:masterfrom
Open
fix(splitter): re-initialize panels when child count changes dynamically#8478YevheniiKotyrlo wants to merge 1 commit intoprimefaces:masterfrom
YevheniiKotyrlo wants to merge 1 commit intoprimefaces:masterfrom
Conversation
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.
Defect Fixes
Fixes #8477
Splitteronly callsinitializePanels()inmounted(). When aSplitterPanelis added dynamically viav-ifafter mount (e.g., waiting for async data), the new panel never receives aflexBasisstyle — it renders at its natural flex size (~27%) instead of the configured:sizepercentage (40%).PR #6394 added
resetState()as a manual workaround, but consumers shouldn't need to call it — the Splitter should handle panel count changes automatically.Related: #5463 (same root cause — closed with manual
resetStateworkaround)Problem
After this fix, dynamically added panels immediately receive the correct
flexBasis:Reproducer:
bun run patchapplies the fix,bun run unpatchreverts.Root cause
initializePanels()queriesthis.$el.childrenfordata-pc-name="splitterpanel"elements and setsflexBasisfrompanel.props.size. Thepanelscomputed (which iterates$slots.default()) correctly includes dynamically added panels, butinitializePanels()never re-runs — the new DOM element has noflexBasisset.Changes
packages/primevue/src/splitter/Splitter.vue: Addupdated()lifecycle hook that tracks panel count via_lastPanelCount. When the count changes (panel added or removed), re-runinitializePanels().The count guard ensures this does not reset user resize state on every re-render — it only fires when panels are actually added or removed.
Scope / Impact
initializePanels(), adds only theupdated()hookv-if, dynamic components, programmatic panel addition/removalVerification
bun run patchapplies fix,bun run unpatchreverts