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

Replacing an absolutely positioned node does not preserve position #792

Closed
rylin8 opened this issue Feb 8, 2024 · 3 comments
Closed

Replacing an absolutely positioned node does not preserve position #792

rylin8 opened this issue Feb 8, 2024 · 3 comments
Assignees
Labels
Milestone

Comments

@rylin8
Copy link
Collaborator

rylin8 commented Feb 8, 2024

A @Composable (ComponentReplacementContext) -> Unit type customization on a node that is absolutely positioned (not in an autolayout) will not preserve the position of the original node. To achieve this, we need to somehow provide the position of the node being replaced to the replacement composable and have it use that instead of its own position.

@rylin8 rylin8 added the layout label Feb 8, 2024
@rylin8 rylin8 self-assigned this Feb 8, 2024
@rylin8
Copy link
Collaborator Author

rylin8 commented Feb 8, 2024

I ran into this issue while experimenting today. I looked into the issue and it did not seem like a quick fix without it being a hack. I'd rather not add another parameter to the already excessively long list of parameters in DesignView.

@HooHaa-code
Copy link

Is this a regression with 0.25? It seemed to work better in 0.24. It appears that adding the node to be replaced in it own frame will allow it to position correctly. However, its making the figma files a bit complicated

rylin8 added a commit that referenced this issue Feb 29, 2024
…odes.

When performing a component replacement, pass the original node's margin into the replacement context. When this margin exists in DesignFrame, replace the current ViewStyle's margin with the context's margin.
rylin8 added a commit that referenced this issue Mar 1, 2024
…odes.

When performing a component replacement, pass the original node's external layout properties into the replacement context. When this  exists in DesignFrame, replace the current ViewStyle's external layout properties with the one in the replacement context.
rylin8 added a commit that referenced this issue Mar 5, 2024
…odes.

When performing a component replacement, pass the original node's external layout properties into the replacement context. When this  exists in DesignFrame, replace the current ViewStyle's external layout properties with the one in the replacement context.
rylin8 added a commit that referenced this issue Mar 8, 2024
…odes.

When performing a component replacement, pass the original node's external layout properties into the replacement context. When this  exists in DesignFrame, replace the current ViewStyle's external layout properties with the one in the replacement context.
@rylin8 rylin8 added this to the 0.25 milestone Mar 11, 2024
rylin8 added a commit that referenced this issue Mar 12, 2024
…odes.

When performing a component replacement, pass the original node's external layout properties into the replacement context. When this  exists in DesignFrame, replace the current ViewStyle's external layout properties with the one in the replacement context.
@rylin8
Copy link
Collaborator Author

rylin8 commented Mar 12, 2024

@HooHaa-code regarding our discussion on changing the size of a component replacement, you showed an example that roughly looks like this. You were doing a component replacement of #ReplaceMe with a #RedBox. The problem was that if a designer resized #RedBox but not #ReplaceMe, then it would still take the size of #ReplaceMe, which is not desired.
Screenshot 2024-03-06 at 4 30 08 PM

Once the pull request for this ticket goes in, you shouldn't need to have a parent frame #ReplaceMe. You can just put #RedBox directly into #stage and rename it to #ReplaceMe. Then, when the component #RedBox changes size, the instance of it in #stage also changes size, so the original and replacement node will always be the same. Does that work for you? Like this:
Screenshot 2024-03-06 at 4 30 25 PM

@rylin8 rylin8 closed this as completed Mar 13, 2024
github-merge-queue bot pushed a commit that referenced this issue Mar 13, 2024
…odes. (#826)

When performing a component replacement, pass the original node's
external layout properties into the replacement context. When this
exists in DesignFrame, replace the current ViewStyle's external layout
properties with the one in the replacement context. This ensures that
the replacement node uses the original node's layout and size
properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

2 participants