Skip to content

Commit 30f7370

Browse files
authored
Merge pull request #106 from Open-STEM/kq-bugs
Addressed issue #102
2 parents 475ef5b + 2c5b4a1 commit 30f7370

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/components/blockly.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ function BlocklyEditor({ name }: BlocklyEditorProps) {
264264
const ws = session?.workspace;
265265
const code = pythonGenerator.workspaceToCode(ws);
266266
if (ws && code) {
267-
session.content = code;
268267
AppMgr.getInstance().emit(EventType.EVENT_GENPYTHON_DONE, code);
269268
}
270269
}
@@ -299,10 +298,12 @@ function BlocklyEditor({ name }: BlocklyEditorProps) {
299298
const json = JSON.stringify(Blockly.serialization.workspaces.save(ws));
300299
EditorMgr.updateLiveContent(name, json);
301300
} catch (e) {
301+
console.warn('Failed to serialize Blockly workspace:', e);
302302
EditorMgr.updateLiveContent(name, '');
303303
}
304304

305305
// Listen for workspace changes
306+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
306307
const changeListener = (event: any) => {
307308
if (event.isUiEvent) return; // Skip UI events
308309
try {

src/components/dialogs/view-pythondlg.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@ import { useTranslation } from 'react-i18next';
44
type ViewPythonDlgProps = {
55
code: string;
66
toggleDlg: () => void;
7+
clearDlg: () => void;
78
};
89

9-
export default function ViewPythonDlg({ code, toggleDlg }: ViewPythonDlgProps) {
10+
export default function ViewPythonDlg({ code, toggleDlg, clearDlg }: ViewPythonDlgProps) {
1011
const { t } = useTranslation();
12+
13+
/**
14+
* handleDlgClose - handle dialog close action
15+
*/
16+
const handleDlgClose = () => {
17+
clearDlg();
18+
toggleDlg();
19+
};
20+
1121
return (
1222
<div className="flex h-auto w-auto flex-col gap-2 overflow-hidden rounded-md border border-mountain-mist-700 p-8 shadow-md transition-all dark:border-shark-500 dark:bg-shark-950">
1323
<div className="flex flex-col items-center">
1424
<button
1525
type="button"
1626
className="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white ms-auto inline-flex h-8 w-8 items-center justify-center rounded-lg text-sm"
17-
onClick={toggleDlg}
27+
onClick={handleDlgClose}
1828
>
1929
<svg
2030
className="h-3 w-3"

src/components/navbar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,9 @@ function NavBar({ layoutref }: NavBarProps) {
474474
* ViewPythonFile - view the Python file
475475
*/
476476
function ViewPythonFile() {
477+
console.log('View Python File', activeTab);
477478
const viewPythonHandler = (code: string) => {
478-
setDialogContent(<ViewPythonDlg code={code} toggleDlg={toggleDialog} />);
479+
setDialogContent(<ViewPythonDlg code={code} toggleDlg={toggleDialog} clearDlg={clearDialogContent}/>);
479480
toggleDialog();
480481
appMgr.eventOff(EventType.EVENT_GENPYTHON_DONE);
481482
};
@@ -771,6 +772,13 @@ function NavBar({ layoutref }: NavBarProps) {
771772
setMoreMenuOpen(!isMoreMenuOpen);
772773
}
773774

775+
/**
776+
* clearDialogContent - toggle the dialog open/close state
777+
*/
778+
function clearDialogContent(){
779+
setDialogContent(<div />);
780+
};
781+
774782
/**
775783
* toggleDialog - toggle the dialog open and closed
776784
*/

0 commit comments

Comments
 (0)