From 979093923b30f4402280c20252f3d6dac00265c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Thu, 8 Jul 2021 00:15:20 +0200 Subject: [PATCH] Colorize trace paths for choose without explicit default case (#9527) Co-authored-by: Bram Kragten --- src/components/trace/hat-script-graph.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/trace/hat-script-graph.ts b/src/components/trace/hat-script-graph.ts index 4a42c5604e..0655e3a016 100644 --- a/src/components/trace/hat-script-graph.ts +++ b/src/components/trace/hat-script-graph.ts @@ -143,11 +143,12 @@ class HatScriptGraph extends LitElement { graphStart = false ) { const trace = this.trace.trace[path] as ChooseActionTraceStep[] | undefined; - const trace_path = trace?.[0].result - ? trace[0].result.choice === "default" - ? [Array.isArray(config.choose) ? config.choose.length : 0] - : [trace[0].result.choice] - : []; + const trace_path = + trace !== undefined + ? trace[0].result === undefined || trace[0].result.choice === "default" + ? [Array.isArray(config.choose) ? config.choose.length : 0] + : [trace[0].result.choice] + : []; return html` ${ensureArray(config.default)?.map((action, i) =>