Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit e623461

Browse files
committed
webui: Remember the "Execute on Enter" state in the execute page
Store the state of the "Execute on Enter" checkbox of the execute page in the local storage of the browser.
1 parent d2326b5 commit e623461

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

webui/jsx/sql-terminal.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function SqlTerminalCommand({command}) {
119119
export default function SqlTerminal() {
120120
const [code, setCode] = React.useState("");
121121
const [recentCommands, setRecentCommands] = React.useState(historyData === null ? [] : historyData);
122-
const [executeOnEnter, setExecuteOnEnter] = React.useState(false);
122+
const [executeOnEnter, setExecuteOnEnter] = React.useState(JSON.parse(localStorage.getItem("sqlTerminal_executeOnEnter")) || false);
123123
const [isDragging, setDragging] = React.useState(false); // We use this to distinguish simple clicks on the component from drag & drop movements. The latter are ignored to not interfere with selecting text for copy & paste.
124124

125125
const editorRef = React.useRef(null);
@@ -195,6 +195,11 @@ export default function SqlTerminal() {
195195
performScrolldown.current = true;
196196
}, [recentCommands]);
197197

198+
// This stores the state of the execute-on-enter flag in the browser local storage
199+
React.useEffect(() => {
200+
localStorage.setItem("sqlTerminal_executeOnEnter", JSON.stringify(executeOnEnter));
201+
}, [executeOnEnter]);
202+
198203
// Handle all mouse click events, used for setting focus to the SQL code editor component even if another
199204
// part of the component has been clicked.
200205
function handleClick(e) {

0 commit comments

Comments
 (0)