etherpad-lite icon indicating copy to clipboard operation
etherpad-lite copied to clipboard

Facility to prevent focus theft when embedded (in Element for example)

Open ScottRochford opened this issue 4 years ago • 14 comments


name: Prevent focus theft about: title: '' labels: enhancement assignees:


Is your feature request related to a problem? Please describe.

Please see this issue reported for the Element chat client (for the Matrix chat protocol), which has a facility to embed Etherpad as a widget:

"reports that etherpad widget can steal keyboard focus entirely from MessageComposer #5130" https://github.com/vector-im/element-web/issues/5130

TL;DR Etherpad takes a significant time to load when entering a room, at which point it steals keyboard input focus (often part-way through typing something), and chaos ensues.

Describe the solution you'd like Would be good to have a way to prevent Etherpad from stealing focus.

Describe alternatives you've considered A change to Element might help, however this is not straightforward according to the dev updates to the issue above.

ScottRochford avatar Apr 08 '21 04:04 ScottRochford

I'm not 100% sure if I understand the problem:

<html>
  <body>
    <textarea id="textarea" name="textarea" rows="10" cols="50">
    </textarea>
    <iframe src='https://paddomain/p/pad#L4?showChat=false&showLineNumbers=false' width=600 height=400>
    </iframe>
  </body>
</html>

During load of this HTML file, I can type in the textarea. However, when etherpad finishes loading, the focus suddenly jumps into the pad. Is this what you mean?

webzwo0i avatar Apr 08 '21 18:04 webzwo0i

Yes, that's exactly what I mean. :-)

ScottRochford avatar Apr 09 '21 06:04 ScottRochford

OK. I think we can detect if we're in an embedded context (ace_inner.parent.parent != window.top) and if yes don't set focus

webzwo0i avatar Apr 09 '21 10:04 webzwo0i

Sounds like a good idea to my untrained ear!

ScottRochford avatar Apr 20 '21 00:04 ScottRochford

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 19 '21 02:06 stale[bot]

Should I comment to keep this one alive? Is this question rhetorical?

ScottRochford avatar Jun 21 '21 01:06 ScottRochford

same here @ScottRochford , Hope this won't be closed. Regards

flotho avatar Jun 23 '21 12:06 flotho

I put forward a patch, I'm a little uneasy about this being a default user experience change tho.. Should we consider putting this under a setting in settings.json? I can imagine some embedded user experiences might want to draw focus on pad load?

JohnMcLear avatar Sep 14 '21 19:09 JohnMcLear

Hi @JohnMcLear you asked a great question. For example we have multiple use cases in our company :

  • Pad is used as a standalone behind an apache proxy
  • Pad is used as an embedded tool in Odoo for task descriptions and collaboration
  • Once we imagined to use the pad as an embedded tool in an homemade software which purpose is to write things

As you can see, with the same installation, we don't need to focus in the odoo installation and we need the focus with the latest case. So you're totally right by saying that having something systematic could not fulfill all the use cases. Having an option should be great and IMHO maybe it should be activated regarding the source of the http query.

Hope this little summary could help you to think about this. Actually, our teams are fan of the pad and they would be very happy to see you achieve this . Is there any way we could contribute even financially ?

Regards

flotho avatar Sep 15 '21 07:09 flotho

RE http query, that's actually really the best approach here. @flotho If you want to contribute we have Github sponsors: https://github.com/ether/ - it's never expected but always appreciated and all funds go to devs.

I will try sort out http param approach today, that should be a walk in the park.

JohnMcLear avatar Sep 15 '21 09:09 JohnMcLear

Ready for testing and feedback :)

JohnMcLear avatar Sep 15 '21 19:09 JohnMcLear

Hi @JohnMcLear , which branch do we need to use for testing ?

Regards

flotho avatar Sep 20 '21 07:09 flotho

Hi @JohnMcLear , which branch do we need to use for testing ?

jm-dont-focus-when-embedded (see pull request #5173)

rhansen avatar Sep 20 '21 09:09 rhansen

Hi @JohnMcLear I'm really happy to inform you that it's working perfectly, Used in Oodo the focus is not taking over the original focus. A big thanks to you!

Regards

flotho avatar Oct 10 '21 19:10 flotho