From c397688a4a8e87f47841c7d552b96a8d5e15cbe5 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 27 Jan 2024 15:01:37 -0500 Subject: [PATCH] Pass uid down from parent. This fixes an issue where lists of nodes did not have the key attribute. --- src/OrgAst.tsx | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/OrgAst.tsx b/src/OrgAst.tsx index c2f1001..009215e 100644 --- a/src/OrgAst.tsx +++ b/src/OrgAst.tsx @@ -1,5 +1,4 @@ import React, { ReactNode, useState } from "react"; -import { parse_org } from "../../organic/target/wasm32-unknown-unknown/js/wasm"; import styles from "./OrgAst.module.css"; const OrgAst = (props: { @@ -21,9 +20,10 @@ const OrgAst = (props: { return (
@@ -34,29 +34,19 @@ const OrgAst = (props: { const OrgAstNode = (props: { selectNode: Function; node: any; - parentUniqueId: string; + uid: string; selectedNode: string; }) => { - const uid = - props.parentUniqueId + - "_" + - props.node["ast-node"] + - "/" + - props.node["standard-properties"]["begin"] + - "/" + - props.node["standard-properties"]["end"] + - "#"; - function selectNode() { props.selectNode( - uid, + props.uid, props.node["standard-properties"]["begin"] - 1, props.node["standard-properties"]["end"] - 1, ); } const nodeClassName = - props.selectedNode === uid + props.selectedNode === props.uid ? styles.OrgAstNode + " " + styles.selected : styles.OrgAstNode; @@ -86,7 +76,7 @@ const OrgAstNode = (props: {
@@ -104,10 +94,20 @@ const OrgAstNodeList = (props: { node_list: any[]; }): React.JSX.Element[] => { return props.node_list.map((node) => { + const uid = + props.parentUniqueId + + "_" + + node["ast-node"] + + "/" + + node["standard-properties"]["begin"] + + "/" + + node["standard-properties"]["end"] + + "#"; return (