mirror of
https://github.com/rio-labs/rio.git
synced 2026-01-02 03:09:48 -06:00
fix DummyClient.get_components returning components in unexpected order
This commit is contained in:
@@ -856,7 +856,7 @@ class SessionRefreshMixin:
|
||||
old_component: rio.Component,
|
||||
new_component: rio.Component,
|
||||
reconciled_components_new_to_old: dict[rio.Component, rio.Component],
|
||||
) -> tuple[set[rio.Component], set[rio.Component]]:
|
||||
) -> None:
|
||||
"""
|
||||
Given two components of the same type, reconcile them. Specifically:
|
||||
|
||||
@@ -919,26 +919,6 @@ class SessionRefreshMixin:
|
||||
|
||||
overridden_values[prop_name] = new_value
|
||||
|
||||
# Keep track of added and removed child components
|
||||
added_children = set[rio.Component]()
|
||||
removed_children = set[rio.Component]()
|
||||
if isinstance(
|
||||
old_component, fundamental_component.FundamentalComponent
|
||||
):
|
||||
child_containing_attributes = (
|
||||
inspection.get_child_component_containing_attribute_names(
|
||||
type(old_component)
|
||||
)
|
||||
)
|
||||
|
||||
for attr_name in child_containing_attributes:
|
||||
removed_children.update(
|
||||
extract_child_components(old_component, attr_name)
|
||||
)
|
||||
added_children.update(
|
||||
extract_child_components(new_component, attr_name)
|
||||
)
|
||||
|
||||
# If the component has changed, mark it as dirty
|
||||
def values_equal(old: object, new: object) -> bool:
|
||||
"""
|
||||
@@ -1007,8 +987,6 @@ class SessionRefreshMixin:
|
||||
# again
|
||||
old_component._on_populate_triggered_ = False
|
||||
|
||||
return added_children, removed_children
|
||||
|
||||
|
||||
def find_components_for_reconciliation(
|
||||
old_build: rio.Component,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import abc
|
||||
import asyncio
|
||||
import collections
|
||||
import typing as t
|
||||
|
||||
import typing_extensions as te
|
||||
@@ -190,7 +191,8 @@ class BaseClient(abc.ABC):
|
||||
component_type: type[C] = rio.Component,
|
||||
key: Key | None = None,
|
||||
) -> t.Iterator[C]:
|
||||
to_do = [self.root_component]
|
||||
to_do = collections.deque()
|
||||
to_do.append(self.root_component)
|
||||
to_do.extend(
|
||||
dialog._root_component
|
||||
for dialog in self.session._fundamental_root_component._owned_dialogs_.values()
|
||||
@@ -198,7 +200,7 @@ class BaseClient(abc.ABC):
|
||||
seen = set[rio.Component]()
|
||||
|
||||
while to_do:
|
||||
component = to_do.pop()
|
||||
component = to_do.popleft()
|
||||
|
||||
if component in seen:
|
||||
continue
|
||||
|
||||
@@ -350,16 +350,16 @@ async def test_margin_reconciliation():
|
||||
|
||||
def build(self) -> rio.Component:
|
||||
if self.switch:
|
||||
return rio.Column(*[rio.Text("hi") for _ in range(7)])
|
||||
return rio.Column(*[rio.Text(f"{num}") for num in range(7)])
|
||||
else:
|
||||
return rio.Column(
|
||||
rio.Text("hi", margin_left=1),
|
||||
rio.Text("hi", margin_right=1),
|
||||
rio.Text("hi", margin_top=1),
|
||||
rio.Text("hi", margin_bottom=1),
|
||||
rio.Text("hi", margin_x=1),
|
||||
rio.Text("hi", margin_y=1),
|
||||
rio.Text("hi", margin=1),
|
||||
rio.Text("0", margin_left=1),
|
||||
rio.Text("1", margin_right=1),
|
||||
rio.Text("2", margin_top=1),
|
||||
rio.Text("3", margin_bottom=1),
|
||||
rio.Text("4", margin_x=1),
|
||||
rio.Text("5", margin_y=1),
|
||||
rio.Text("6", margin=1),
|
||||
)
|
||||
|
||||
async with rio.testing.DummyClient(RootComponent) as test_client:
|
||||
|
||||
Reference in New Issue
Block a user