@@ -65,6 +65,12 @@ export function QueryEditor({ query, onChange, onRunQuery, datasource }: Props)
65
65
const [ queryStr , setQueryStr ] = React . useState ( '' ) ;
66
66
const { apl : queryText } = query ;
67
67
68
+ if ( query . apl !== queryStr ) {
69
+ // query.apl could've changed from the outside (e.g. when a history query
70
+ // is ran), so we need to update the state.
71
+ setQueryStr ( query . apl ) ;
72
+ }
73
+
68
74
const onQueryTextChange = ( apl : string ) => {
69
75
onChange ( { ...query , apl } ) ;
70
76
setQueryStr ( apl ) ;
@@ -79,7 +85,9 @@ export function QueryEditor({ query, onChange, onRunQuery, datasource }: Props)
79
85
} ;
80
86
81
87
const addPlaceholder = ( editor : any , monaco : any ) => {
82
- editor . executeEdits ( null , [ { range : new monaco . Range ( 1 , 1 , 1 , 1 ) , text : placeholder } ] ) ;
88
+ if ( editor . getValue ( ) === '' ) {
89
+ editor . executeEdits ( null , [ { range : new monaco . Range ( 1 , 1 , 1 , 1 ) , text : placeholder } ] ) ;
90
+ }
83
91
editor . onDidFocusEditorText ( ( ) => {
84
92
if ( editor . getValue ( ) === placeholder ) {
85
93
editor . executeEdits ( null , [ { range : new monaco . Range ( 1 , 1 , placeholder . length , 1 ) , text : '' } ] ) ;
0 commit comments