WordPress / press-this

Press This is a little tool that lets you grab bits of the web and create new posts with ease. It will even allow you to choose from images or videos included on the page and use them in your post. Use Press This as a quick and lightweight way to highlight another page on the web.
49 stars 22 forks source link

It would be cool that upon displaying the Press-This Window, the cursor would either focus on `title-container` or `tinymce` #49

Open jpluimers opened 2 years ago

jpluimers commented 2 years ago

From an #a11y perspective, it is important to support users that mainly depend on keyboard input.

Currently when running the Press-This bookmarklet (I use it from https://wiert.wordpress.com with the latest Chrome browser) it is very unclear where the keyboard focus is: no cursor blinks, nothing is highlighted with "focus" indication.

When the Press-This Window shows, it takes two tab-key presses to get to the title-container and 3 more tab-key presses to get to tinymce (which itself is inside pressthis_ifr).

My own main usage workflow is that I always start in tinymce, so have to switch to a pointing device, then click there to get started or have to remember to press the tab-key exactly 5 times.

I think it would be really cool that when the Press-This Window shows, the keyboard focus would either be on the title-container or the tinymce.

I wish I would be more well-versed in JavaScript/PHP and having a local WordPress installation playground to be able to submit a pull request myself.

For now, I fiddled around a bit in the dev-console of Chrome and can leave only some notes for implementing this.

  1. document.getElementById('title-container').focus(); gets the focus to title-container.
  2. document.getElementById('tinymce').focus(); fails to get the focus to tinymce.
  3. document.getElementById("pressthis_ifr").contentWindow.document.getElementById("tinymce").focus(); fails to get the focus to tinymce.
  4. Likely a <script> block needs to be added to https://github.com/WordPress/press-this/blob/trunk/class-wp-press-this-plugin.php which only fires a focus mechanism when the complete document and <iframe> containing pressthis_ifr are loaded.
  5. Maybe some of the above bits are specific to Chrome, so need to be generalised more.
  6. Maybe some hard-coded strings above should be more centralised in https://github.com/WordPress/press-this/blob/trunk/class-wp-press-this-plugin.php to avoid Don't_repeat_yourself.

Hopefully these give a more seasoned WordPress developer enough information to implement something like this.