deathandmayhem / jolly-roger

Dead men tell no tales!
MIT License
19 stars 6 forks source link

Focus issues when trying to add solution to unopened puzzle #2283

Open jpd236 opened 1 month ago

jpd236 commented 1 month ago

Occasionally, we may need to open a puzzle and immediately mark it as solved (imagine we just solved it without first adding it to the sheet, or weren't actively editing it but now have an answer to submit, e.g. because we had to wait for HQ to evaluate a creative submission).

The natural way to do this is to open the puzzle and immediately click Answer. But what commonly happens is that you do this, and then Sheets steals focus from the dialog, so you start typing the answer into the sheet itself, which is unexpected given that the dialog should be a modal over the whole page. (Presumably this might also affect other dialogs like the "Edit" one, but it was less critical there in our experience).

One thought would be to see if there's a way we can force holding focus or reclaim it if taken by Docs/Sheets. I wonder if an onBlur listener on the dialog/text field that checks if focus has moved to somewhere within the Sheet iframe and, if so, refocuses the dialog/text field might work without causing too much disruption?

Another thought could be to provide a way to submit answers from the puzzle list view.

jpd236 commented 3 weeks ago

I tried the focus hack approach, adding an onBlur handler to the answer input in the dialog which restores focus back if it is lost to the puzzle iframe.

It seems to work... okay. If I type very quickly, I can get a character into the spreadsheet before focus is restored back. That seems hard to avoid with this approach.

So it feels to me like the better approach here would be to add a way to submit answers from the list view without having to open the puzzle page. Maybe a button next to the "Open puzzle" link which launches the answer dialog?