diff --git a/sway/tree/container.c b/sway/tree/container.c
index ef44c9440..7068e166d 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1324,8 +1324,12 @@ void container_replace(struct sway_container *container,
 		root_scratchpad_remove_container(container);
 	}
 	if (container->parent || container->workspace) {
+		float width_fraction = container->width_fraction;
+		float height_fraction = container->height_fraction;
 		container_add_sibling(container, replacement, 1);
 		container_detach(container);
+		replacement->width_fraction = width_fraction;
+		replacement->height_fraction = height_fraction;
 	}
 	if (scratchpad) {
 		root_scratchpad_add_container(replacement, ws);