UC-Davis-molecular-computing / scadnano

Web application for designing DNA structures such as DNA origami.
https://scadnano.org
MIT License
23 stars 13 forks source link

fix oxView focus stealing #979

Open dave-doty opened 2 months ago

dave-doty commented 2 months ago

If you click in the oxView window, that iframe takes the focus, and scadnano keyboard shortcuts no longer work even though we are listening on document.body, but perhaps iframes are considered not part of the body since they host a whole other webpage.

Perhaps this is necessary, but the crazy thing is that if you click in the scadnano main view, even selecting strands and editing, it does not return the focus to scadnano, so pressing, e..g, delete, will delete the selected base in oxView rather than the selected strand in scadnano.

Focus can be restored by clicking on the menu or separators or other non-SVG.

However, ideally:

  1. clicking anywhere outside of the iframe should restore the focus to main view.
  2. Even more ideally, we redirect keyboard events from the iframe to scadnano so that keyboard shortcuts are always interpreted by scadnano. Perhaps we want to relax this or make it optional if we manage to get more editing capabilities in the oxView window, but for now since it is read-only from the perspective of scadnano (no changes are propagated back to scadnano), it makes sense for keyboard shortcuts always to be interpreted by scadnano rather than oxView.
dave-doty commented 2 months ago

Looks like the only way around this (since we are hosting from different sites) is to send a POST message from oxView to scadnano telling it about the key events: https://stackoverflow.com/questions/9393532/cross-domain-iframe-issue