uclaacm / TeachLAFrontend

🌱 The frontend for Teach LA's online IDE, designed to teach kids how to code!
https://editor.uclaacm.com
MIT License
20 stars 39 forks source link

bug(python): clicking "Show Console"/"Hide Console" doesn't show/hide console and creates extra output #1054

Open TomBinford opened 1 year ago

TomBinford commented 1 year ago
  1. Create a Python sketch containing print('a')
  2. Run the sketch. As expected, console shows
    > a
  3. Click the "Hide Console" button. Console remains visible and shows
    > a
    > a
  4. Click the same button, now "Show Console". Console shows
    > a
    > a
    > a

    Clicking "Run" at any point changes the output to a single line as expected.

TomBinford commented 1 year ago

The hiding problem comes from CreatePythonDoc at https://github.com/uclaacm/TeachLAFrontend/blob/aad5874f0a08730ce8d2e28a795b167409b91ccf/src/util/languages/Python.js#L3 It only takes one parameter for the source code, while the caller at https://github.com/uclaacm/TeachLAFrontend/blob/aad5874f0a08730ce8d2e28a795b167409b91ccf/src/components/Output/Output.js#L74 passes the showConsole parameter that should be respected. This likely comes down to us telling the Skulpt interpreter to output directly to the div with id="inner", which we aren't controlling the visibility of. Hopefully the fix is as simple as adjusting CSS visibility in CreatePythonDoc depending on the showConsole parameter; see an example at https://github.com/uclaacm/TeachLAFrontend/blob/aad5874f0a08730ce8d2e28a795b167409b91ccf/src/util/languages/React.js#L61-L63