diff --git a/CHANGELOG.md b/CHANGELOG.md index ea37974..13eae5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## v1.7.10 + +- Tweaks in type definitions for the `SQLEditor` component on the `blur` method ## v1.7.9 diff --git a/package.json b/package.json index 5f24b3b..32f8830 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@grafana/experimental", - "version": "1.7.9", + "version": "1.7.10", "description": "Experimental Grafana components and APIs", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/sql-editor/components/SQLEditor.tsx b/src/sql-editor/components/SQLEditor.tsx index 247b0c6..a911510 100644 --- a/src/sql-editor/components/SQLEditor.tsx +++ b/src/sql-editor/components/SQLEditor.tsx @@ -52,7 +52,7 @@ interface SQLEditorProps { * Use for inspecting the query as it changes. I.e. for validation. */ onChange?: (q: string, processQuery: boolean) => void; - onBlur?: () => void; + onBlur?: (text: string) => void; language?: LanguageDefinition; children?: (props: { formatQuery: () => void }) => React.ReactNode; width?: number; @@ -104,6 +104,11 @@ export const SQLEditor: React.FC = ({ } }, []); + const onSqlBlur = (text: string) => { + onChange && onChange(text, false); + onBlur && onBlur(text); + }; + return (
= ({ width={width ? `${width - 2}px` : undefined} language={id} value={query} - onBlur={(v) => { - onChange && onChange(v, false); - onBlur && onBlur(); - }} + onBlur={onSqlBlur} showMiniMap={false} showLineNumbers={true} // Using onEditorDidMount instead of onBeforeEditorMount to support Grafana < 8.2.x @@ -403,13 +405,13 @@ function extendStandardRegistries(id: string, lid: string, customProvider: SQLCo const columns = await customProvider.columns?.resolve!(tableIdentifier); oo = columns ? columns.map((x) => ({ - label: x.name, - insertText: x.completion ?? x.name, - kind: CompletionItemKind.Field, - sortText: CompletionItemPriority.High, - detail: x.type, - documentation: x.description, - })) + label: x.name, + insertText: x.completion ?? x.name, + kind: CompletionItemKind.Field, + sortText: CompletionItemPriority.High, + detail: x.type, + documentation: x.description, + })) : []; } return [...o, ...oo];