From 47c6bd6963ac163f714bdeb9ad5704ed58395e77 Mon Sep 17 00:00:00 2001 From: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Date: Fri, 24 Apr 2020 09:45:44 +0200 Subject: [PATCH] Fix PromQuery cascader when selected option has no children (#23835) --- .../datasource/prometheus/components/PromQueryField.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx b/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx index f0390639d91..efa1326d6ae 100644 --- a/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx +++ b/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx @@ -199,8 +199,9 @@ class PromQueryField extends React.PureComponent { let query; if (selectedOptions.length === 1) { - if (selectedOptions[0].children.length === 0) { - query = selectedOptions[0].value; + const selectedOption = selectedOptions[0]; + if (!selectedOption.children || selectedOption.children.length === 0) { + query = selectedOption.value; } else { // Ignore click on group return;