Hey !

So we got this keyboard navigation bug with flag on some browser.

Step to reproduce :

  1. Navigate to the flag icon / link with tab
  2. Press enter to un/flag the content
  3. The focus is lost after the return of ajax callback

On firefox it's not a big issue, tabbing one more time put the focus back on the icon, but on browsers like Chromium, the focus is sent back to the beginning of the document, which is a big accessibility problem (stopping us from our AA accessibility grade, damn…).

So what I was thinking about was to add a Command after the operation, in Controller/ActionLinkController.php, somewhere like // Create a new JQuery Replace command to update the link display. in order to put the focus back on the element when the replace is over, with maybe a small delay or something else.

I'd really like to solve this issue, every feedback / advice is well appreciated.

Thanks !

CommentFileSizeAuthor
#5 2901287-5.patch993 bytesidebr
#3 focusbackonlink-2901287-3.patch935 bytessylvainar

Issue fork flag-2901287

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sylvainar created an issue. See original summary.

andrewmacpherson’s picture

keyboard focus is a tag we already use.

sylvainar’s picture

Status: Active » Needs review
StatusFileSize
new935 bytes

It was actually easier than I thought. Anyway it solves our keyboard navigation problem.

Status: Needs review » Needs work

The last submitted patch, 3: focusbackonlink-2901287-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new993 bytes
ivnish’s picture

Status: Needs review » Needs work
Issue tags: -Accessibility, -keyboard focus +Needs reroll

prem suthar made their first commit to this issue’s fork.

prem suthar’s picture

Status: Needs work » Needs review
ivnish’s picture

Issue tags: -Needs reroll

  • ivnish committed a8d7a235 on 8.x-4.x authored by prem suthar
    Issue #2901287: Accessibility : Focus lost when link is clicked
    
ivnish’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ivnish’s picture

Version: 8.x-4.x-dev » 5.x-dev
Status: Closed (fixed) » Needs work
anybody’s picture

Thanks @ivnish I can confirm this issue and just ran into this using the last stable release: #3553976: Flag Action Ajax Link "focus" command jumps to wrong flag, if there are multiple on the page (I'll close it as duplicate of #3524123: Implementation of 2901287 causes issues when multiple instances of a flag are rendered on page which I just found.

So this definitely should not be added, see my issue. I don't think the focus can work properly, as we never know which of the buttons were clicked.

Could you maybe tag a new stable release with the reverted code? Thank you!

I'd vote to close this won't fix or we need a quite complicated solution, that might not be worth it? Another alternative might be to solve the focus directly on the clicked element in JS?

deaom’s picture

I can confirm the issue and even add to it, as it's not just focus that's the issue. If you have multiple flags that are the same (like bookmark) added to the page, they all have the same id/selector that is added via the ajax command, meaning that the click gets lost as ajax command replaces the whole selector bit (click event is added to the a element inside flag div). So ajax does not have the information on which flag/link was actually clicked, so the text that is displayed after flag/unflag is displayed on the first flag.
When the focus part of the code is removed, the focus does not return to the selected a element, but when pressing the tab again it does jump to the right link. It was reported this only working correctly in firefox, but tested in Chrome and it works the same there as well.
If multiple flags added with the same selector is something that the module supports, this issue can be re-used for that as then the focus can be added via JS. I played around for a bit and it gets a little complicated for me with JS.

anybody’s picture

@deaom thanks, you basically found out the same as I did in #3553976: Flag Action Ajax Link "focus" command jumps to wrong flag, if there are multiple on the page :D

So I think it's really important to have a stable release for now, publishing the revert. Afterwards this seems to be a quite complicated logical issue ;)

ivnish’s picture

@anybody

I'm on vacation now, but a new release was created :)