brownplt / code.pyret.org

Website for serving Pyret to folks.
Other
24 stars 45 forks source link

[VMT] hacky focus fix #415

Closed anzook closed 2 years ago

anzook commented 2 years ago

A very hacky fix for the interaction panel stealing focus on the receipt of an interaction event from another user in VMT.

Currently setting the CodeMirror repl-promt class as readOnly nocursor (no focusing)

jpolitz commented 2 years ago

Some more commentary – I'm pretty sure this has to be handled Pyret-side because focus is so hard to manage in the browser, and CPO does a programmatic focus of the next interaction after each interaction runs.

This hack has some nice properties – it doesn't require plumbing through any flags about synthetic events, etc. It clearly happens around the extent of the run of interactions and "undoes" itself.

However, it's super brittle DOM-wise. So maybe the best thing to do is add an extra entrypoint on runner that toggles whether the next interaction should be nocursor or not.

Also if @blerner or someone knows a way to make it so a surrounding page can stop elements in an iframe from getting focused, this could be solved (and usefully solved for other apps) VMT-side.

blerner commented 2 years ago

Pretty certain a surrounding page can't affect the dispatch process of events within an iframe, since that would break most of the security properties of iframes...

anzook commented 2 years ago

Updating the code led to unnecessary commits- if this is merged, I recommend either 'squash and merge' or I can rebase to a single commit.

jpolitz commented 2 years ago

Merging to test live.