Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get unexpected results when clicking run after loading a document for the first time #1568

Closed
wlach opened this issue Mar 1, 2019 · 7 comments

Comments

@wlach
Copy link
Contributor

wlach commented Mar 1, 2019

A colleague of mine loaded this notebook and clicked on the play button:

https://extremely-alpha.iodide.io/notebooks/139/

And then got this error:

ReferenceError: pyodide is not defined

It seems like when you first load a document and press play, it evaluates the last cell by default? I guess because that's where the caret position is by default. Here's a simplified notebook that demonstrates the problem:

https://definitely-staging.iodide.io/notebooks/8/

Should we disable the play button when not in the text area? Or set the caret position to 0 by default? Or something else entirely? I think the current interaction model isn't at all clear for someone unfamiliar with iodide who just gets a link to a notebook like the above.

@wlach wlach added the client UX label Mar 1, 2019
@hamilton
Copy link
Contributor

hamilton commented Mar 1, 2019

Great catch. We should be defaulting the caret position to 0 by default, I think. @bcolloran thoughts there?

@bcolloran
Copy link
Contributor

ah yes, we should definitely be defaulting the cursor pos to 0.

longer term/more correct solution: we should move the current cursor position into the redux store and fire an action to update it whenever the cursor moves, instead of just checking the cursor position inside of the evaluateText action. this will more cleanly decouple the actions from the internals of the editor, which will (1) push this into our state tree, where we have more kinds of sanity checking and thus bugs like this are easier to to catch in advance, and (2) make it easier to migrate to Monaco down the line. (I don't know why i didn't do this to begin with -- this was my bad during the jsmd migration)

@wlach
Copy link
Contributor Author

wlach commented Mar 5, 2019

ah yes, we should definitely be defaulting the cursor pos to 0.

longer term/more correct solution: we should move the current cursor position into the redux store and fire an action to update it whenever the cursor moves, instead of just checking the cursor position inside of the evaluateText action. this will more cleanly decouple the actions from the internals of the editor, which will (1) push this into our state tree, where we have more kinds of sanity checking and thus bugs like this are easier to to catch in advance, and (2) make it easier to migrate to Monaco down the line. (I don't know why i didn't do this to begin with -- this was my bad during the jsmd migration)

Yup this sounds like the right solution looking at the code. Until we have time to do that, I have an interim patch in #1582 which does the simple thing we talk about above.

@hamilton
Copy link
Contributor

hamilton commented Mar 7, 2019

@wlach @bcolloran would you argue that we've fixed the immediate issue here? I understand there is a better medium-term fix to be done but at least we've fixed this rough edge for now.

@hamilton
Copy link
Contributor

hamilton commented Mar 7, 2019

(and maybe should close this)

@wlach
Copy link
Contributor Author

wlach commented Mar 7, 2019

@wlach @bcolloran would you argue that we've fixed the immediate issue here? I understand there is a better medium-term fix to be done but at least we've fixed this rough edge for now.

We could file a new issue with @bcolloran's suggestions above, though I'm not sure what the priority should be. I'll defer to him.

@bcolloran
Copy link
Contributor

i'll file a new issue. i plan to look at this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants