File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
packages/compass-components/src/components/document-list Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -420,6 +420,25 @@ const isValidUrl = (str: string): boolean => {
420420 }
421421} ;
422422
423+ const getNestedKeyPath = ( element : HadronElementType ) : string => {
424+ let keyPath = '' ;
425+ let currentElement : HadronElementType | HadronDocumentType | null = element ;
426+ while (
427+ currentElement &&
428+ 'parent' in currentElement &&
429+ currentElement . parent
430+ ) {
431+ if ( currentElement . parent . currentType !== 'Array' ) {
432+ keyPath =
433+ keyPath === ''
434+ ? currentElement . currentKey . toString ( )
435+ : currentElement . currentKey . toString ( ) + '.' + keyPath ;
436+ }
437+ currentElement = currentElement . parent ;
438+ }
439+ return keyPath ;
440+ } ;
441+
423442export const HadronElement : React . FunctionComponent < {
424443 value : HadronElementType ;
425444 editable : boolean ;
@@ -469,7 +488,10 @@ export const HadronElement: React.FunctionComponent<{
469488 {
470489 label : 'Add to query' ,
471490 onAction : ( ) => {
472- onAddToQuery ( key . value , element . generateObject ( ) ) ;
491+ onAddToQuery (
492+ getNestedKeyPath ( element ) ,
493+ element . generateObject ( )
494+ ) ;
473495 } ,
474496 } ,
475497 ]
You can’t perform that action at this time.
0 commit comments