Repository navigation
Fix mj-wrapper children disappearing after a child is added or removed - #442
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
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.
Fixes #385
Problem
After you add or remove a section inside an
mj-wrapper, changing any wrapper property (for example, the background color) removes every child section from the canvas. The components stay in the model, so the export is correct, but the editor shows an empty wrapper.Cause
The wrapper listens to
add removeon its components and callsrenderChildren()directly.renderChildren()moves the child elements into the container and leavesthis.childNodespointing at the now-emptychildNodeslist of the children view.render()refreshesthis.childNodesafterrenderChildren(), but the listener does not. The nextrerender()(triggered bychange:attributes) replaces the wrapper HTML and moves the nodes inthis.childNodesinto the new container, which is an empty list.Fix
After the listener renders the children, store the container
childNodes, the same wayrender()does.Tests
tests/specs/wrapper.test.tscovers both the remove and the add case: it changes a wrapper attribute and checks that the remaining section elements are still rendered inside the wrapper. Both tests fail without the fix and pass with it. The full suite (36 tests),npm run lint, andnpm run typecheckpass.