Skip to content

Commit

Permalink
fix Fragments not updating conditionally inside Portals
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloomca committed Oct 14, 2024
1 parent 48fa7e0 commit 8c38282
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions integration-tests/portals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,11 @@ describe("portals", () => {
`portal titleportal container`
);

fragmentShowState.setValue(true);
expect(screen.getByTestId("portal").textContent).toBe(
`portal titleportal fragment titlefragment string1fragment componentportal container`
);

checkCleanup();
});
});
9 changes: 8 additions & 1 deletion src/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ function renderTree(
// if there is a portal, we don't need to render directly
// instead, we need to do so in the mount callback
if (component.portal) {
// it is handled by the portal parent element
/**
* Inserting nodes is handled by the portal parent element.
* We still need to assign `parentVelesElement`, so that
* `useValue` updates correctly
*/
if (parentVelesElement) {
newNode.parentVelesElement = parentVelesElement;
}
} else if (parentVelesElement) {
if (component.insertAfter) {
if ("velesComponentObject" in component.insertAfter) {
Expand Down

0 comments on commit 8c38282

Please sign in to comment.