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

skip calling getRemixValidPathsGenerationContext if not in remixScene #6073

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 44 additions & 42 deletions editor/src/components/canvas/canvas-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1774,55 +1774,57 @@ function getValidElementPathsFromElement(
let paths = includeElementInPath ? [path] : []
if (isJSXElementLike(element)) {
const isRemixScene = isRemixSceneElement(element, filePath, projectContents)
const remixPathGenerationContext = getRemixValidPathsGenerationContext(path)
if (remixPathGenerationContext.type === 'active' && isRemixScene) {
function makeValidPathsFromModule(routeModulePath: string, parentPathInner: ElementPath) {
const file = getProjectFileByFilePath(projectContents, routeModulePath)
if (file == null || file.type !== 'TEXT_FILE') {
return
}
if (isRemixScene) {
const remixPathGenerationContext = getRemixValidPathsGenerationContext(path)
if (remixPathGenerationContext.type === 'active') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide Whitespace recommended

function makeValidPathsFromModule(routeModulePath: string, parentPathInner: ElementPath) {
const file = getProjectFileByFilePath(projectContents, routeModulePath)
if (file == null || file.type !== 'TEXT_FILE') {
return
}

const topLevelElement = getDefaultExportedTopLevelElement(file)
const topLevelElement = getDefaultExportedTopLevelElement(file)

if (topLevelElement == null) {
return
}
if (topLevelElement == null) {
return
}

paths.push(
...getValidElementPathsFromElement(
focusedElementPath,
topLevelElement,
parentPathInner,
projectContents,
autoFocusedPaths,
routeModulePath,
uiFilePath,
false,
true,
true,
resolve,
getRemixValidPathsGenerationContext,
),
)
}
paths.push(
...getValidElementPathsFromElement(
focusedElementPath,
topLevelElement,
parentPathInner,
projectContents,
autoFocusedPaths,
routeModulePath,
uiFilePath,
false,
true,
true,
resolve,
getRemixValidPathsGenerationContext,
),
)
}

/**
* The null check is here to guard against the case when a route with children is missing an outlet
* that would render the children
*/

for (const route of remixPathGenerationContext.currentlyRenderedRouteModules) {
const entry = remixPathGenerationContext.routeModulesToRelativePaths[route.id]
if (entry != null) {
const { relativePaths, filePath: filePathOfRouteModule } = entry
for (const relativePath of relativePaths) {
const basePath = EP.appendTwoPaths(path, relativePath)
makeValidPathsFromModule(filePathOfRouteModule, basePath)
/**
* The null check is here to guard against the case when a route with children is missing an outlet
* that would render the children
*/

for (const route of remixPathGenerationContext.currentlyRenderedRouteModules) {
const entry = remixPathGenerationContext.routeModulesToRelativePaths[route.id]
if (entry != null) {
const { relativePaths, filePath: filePathOfRouteModule } = entry
for (const relativePath of relativePaths) {
const basePath = EP.appendTwoPaths(path, relativePath)
makeValidPathsFromModule(filePathOfRouteModule, basePath)
}
}
}
}

return paths
return paths
}
}

const isScene = isSceneElement(element, filePath, projectContents)
Expand Down
Loading