Skip to content

Commit 1f509ee

Browse files
authored
fix(explorer): preserve sql query formatting (#3810)
1 parent bd97268 commit 1f509ee

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.changeset/stupid-cameras-greet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/explorer": patch
3+
---
4+
5+
Formatting is now preserved when re-running SQL queries.

packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/SQLEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export function SQLEditor({ table, isLiveQuery, setIsLiveQuery }: Props) {
119119
value={decodeURIComponent(field.value)}
120120
options={monacoOptions}
121121
language="sql"
122-
onChange={(value) => field.onChange(encodeURIComponent(value ?? ""))}
122+
onChange={(value) => field.onChange(value ?? "")}
123123
onMount={(editor, monaco) => {
124124
editorRef.current = editor;
125125
monaco.editor.defineTheme("custom-vs-dark", {

packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/hooks/useSQLQueryState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ type UseSQLQueryStateReturn = [string, (value: string) => void];
44

55
export function useSQLQueryState(): UseSQLQueryStateReturn {
66
const [query, setQuery] = useQueryState("query", parseAsString.withDefault(""));
7-
return [decodeURIComponent(query), setQuery];
7+
return [decodeURIComponent(query), (value: string) => setQuery(encodeURIComponent(value))];
88
}

0 commit comments

Comments
 (0)