Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix disappearing content during interaction #6094

Merged
merged 11 commits into from
Jul 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export function createComponentRendererComponent(params: {
null,
)
}
} else if (shouldUpdate()) {
} else if (shouldUpdate() || buildResult.current === null) {
buildResult.current = buildComponentRenderResult(utopiaJsxComponent.rootElement)
}
return buildResult.current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ export var whatever = ({prop, ...otherProps}) => {
}
`

const codeWithDestructuredPropsObjectWithElementNamePropAndRestParam = `import React from "react";
export var whatever = ({As = 'div', ...otherProps}) => {
return (
<As data-uid={'aaa'} />
)
}
`

const codeWithDestructuredArray = `import React from "react";
import { View } from "utopia-api";
export var whatever = ([prop]) => {
Expand Down Expand Up @@ -1059,6 +1067,10 @@ describe('Parsing, printing, reparsing a function component with props', () => {
testParsePrintParse(codeWithDestructuredPropsObjectWithRestParam)
})

it('Correctly parses back and forth a destructured props object with element name prop and rest param', () => {
testParsePrintParse(codeWithDestructuredPropsObjectWithElementNamePropAndRestParam)
})

it('Correctly parses back and forth a destructured props array', () => {
testParsePrintParse(codeWithDestructuredArray)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import {
jsAssignmentStatement,
clearAssignmentUniqueIDsAndSourceMaps,
clearJSExpressionOtherJavaScriptUniqueIDs,
propertiesExposedByParams,
} from '../../shared/element-template'
import { maybeToArray, forceNotNull } from '../../shared/optional-utils'
import type {
Expand Down Expand Up @@ -4105,7 +4106,7 @@ export function parseOutFunctionContents(
jsBlock = null
}

let declared: Array<string> = [...topLevelNames]
let declared: Array<string> = [...topLevelNames, ...propertiesExposedByParams(params)]
if (jsBlock != null) {
declared.push(...jsBlock.definedWithin)
}
Expand Down
Loading