Added tests for Layout and Treeview

This commit is contained in:
2025-12-05 17:46:15 +01:00
parent 7c701a9116
commit 8f2528787a
21 changed files with 1161 additions and 229 deletions

View File

@@ -334,12 +334,11 @@ class TreeView(MultipleInstance):
# Toggle icon
toggle = mk.icon(
chevron_down20_regular if is_expanded else chevron_right20_regular if has_children else " ",
chevron_down20_regular if is_expanded else chevron_right20_regular if has_children else None,
command=self.commands.toggle_node(node_id))
# Label or input for editing
if is_editing:
# TODO: Bind input to save_rename (Enter) and cancel_rename (Escape)
label_element = mk.mk(Input(
name="node_label",
value=node.label,
@@ -357,7 +356,6 @@ class TreeView(MultipleInstance):
label_element,
self._render_action_buttons(node_id),
cls=f"mf-treenode flex {'selected' if is_selected and not is_editing else ''}",
data_node_id=node_id,
style=f"padding-left: {level * 20}px"
)
@@ -372,7 +370,8 @@ class TreeView(MultipleInstance):
return Div(
node_element,
*children_elements,
cls="mf-treenode-container"
cls="mf-treenode-container",
data_node_id=node_id,
)
def render(self):
@@ -390,7 +389,7 @@ class TreeView(MultipleInstance):
return Div(
*[self._render_node(node_id) for node_id in root_nodes],
Keyboard(self, {"esc": self.commands.cancel_rename()}, _id="_keyboard"),
Keyboard(self, {"esc": self.commands.cancel_rename()}, _id="-keyboard"),
id=self._id,
cls="mf-treeview"
)