Decide where the focus should return to when a tip dialog modal is closed

Created on 21 August 2024, about 2 months ago
Updated 13 September 2024, about 1 month ago

Problem/Motivation

For dialog modals the recommendation is to return the focus to the element that opened the dialog modal in the first place (for example https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/dialog/). At the moment the focus goes back to the top of the page. This might be unexpected and confusing for the user.

Steps to reproduce

  • Go to admin/appearance
  • open the tour
  • press ESC
  • Check where the focus returns to and what the next focusable element is

Proposed resolution

There are two options here, either return to the "Take a tour of this page" button no matter on which tip the tour currently is, or as suggested by @andrewmacpherson when closing a dialog modal return to the ui component the tip was currently hightlighting. The latter sounds like an interesting idea but could also be potentially confusing and unexpected outcome for the user.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

2.0

Component

User interface

Created by

🇩🇪Germany rkoller Nürnberg, Germany

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @rkoller
  • 🇩🇪Germany rkoller Nürnberg, Germany
  • 🇺🇸United States smustgrave

    From my understanding of a modal the focus has to return to where it started. So it should return to the "take tour" button.

  • 🇩🇪Germany rkoller Nürnberg, Germany

    yep i am also leaning towards that approach

  • Assigned to pooja_sharma
  • First commit to issue fork.
  • Issue was unassigned.
  • Status changed to Needs review about 2 months ago
  • 🇮🇳India shalini_jha

    I have added the CSS for highlight the "Take a Tour" button once the model popup close. please review.

  • Pipeline finished with Success
    about 2 months ago
    Total: 302s
    #266707
  • Status changed to RTBC about 2 months ago
  • I have verified & applied changes working fine for me, on click on modal close button , "Take a tour button page" button highlight with grey color & attached the screencast as well moving to RTBC.

  • Status changed to Needs work about 2 months ago
  • 🇺🇸United States smustgrave

    Can the eslint issue be addressed.

    possible to do with vaniella javascript vs jquery?

  • Assigned to shalini_jha
  • Pipeline finished with Success
    about 2 months ago
    Total: 434s
    #267196
  • Pipeline finished with Failed
    about 2 months ago
    Total: 815s
    #267226
  • Pipeline finished with Success
    about 2 months ago
    Total: 302s
    #267742
  • Issue was unassigned.
  • Status changed to Needs review about 2 months ago
  • 🇮🇳India shalini_jha

    I've addressed the feedback by replacing the jQuery line with vanilla JavaScript. this resolved the ESLint issues in the pipeline, Thank you for the guidance, Please review.

  • Status changed to Needs work about 2 months ago
  • 🇩🇪Germany rkoller Nürnberg, Germany

    thanks for working on the MR. I've quickly tested and i have one observation and one general question.

    You were adding the focus with that.el.style.border = '2px solid gray';. That way your are using your own focus outline and dont use the focus outline set for the theme.with admin_toolbar as the toolbar the color contrast is too low and the outline barely visible. it doesnt mean the actual focus outline would be meeting SC2.4.7 with admin toolbar but still i would use the themes focus styling by for example using the focus() method in javascript?

    the only question i am not sure 100% about is how to handle the case when the toolbar is available for a user, the user is on a page in the frontend that has added the tour button and that page has a tour? which of the two buttons to focus? strictly speaking tour would have to remember which of the two was pressed for starting the tour and fall back to this one with the focus when the tour is exited?

  • Status changed to Needs review about 2 months ago
  • 🇺🇸United States smustgrave

    Updated for focus call.

  • Status changed to Needs work about 2 months ago
  • 🇩🇪Germany rkoller Nürnberg, Germany

    thanks! I've tested three scenarios:

    1) I've started a tour on admin/appearance (as admin). the focus gets back to the "take a tour of this page" button when the tour is closed.
    2) When i am on a page for a node node/2 as admin and i have the "take a tour of this page" button in the admin_toolbar and the socials sidebar in olivero the focus always returns to the button in the sidebar when the tour is closed (no matter which of the two buttons was used to open the tour) .
    3) when i open node/2 in a private window, open the tour by pressing the button in the social sidebar, and close the tour again the button in the social sidebar isnt regaining focus.

    i'll set back the issue to needs work. point 3 should be fixed within this issue imho. point 2 is up to debate how to handle the redundant button case, but guess better in a followup?

  • Status changed to Needs review about 2 months ago
  • 🇺🇸United States smustgrave

    #3 you sure? I tested the same wayand focus goes right back to the button.

  • 🇩🇪Germany rkoller Nürnberg, Germany

    yes i am sure. and Interesting i think i figured out why i havent seen a focus outline. i've closed the tour tip by the mouse. take a look at the brief video. first just navigated by the keyboard in the second try i used the mouse for closing the tour tip.

  • 🇺🇸United States smustgrave

    Pushed a new fix if that doesn't fix it and @shalini_jha doesn't pick it back up over night will try and look at Monday.

  • Status changed to RTBC about 2 months ago
  • 🇩🇪Germany rkoller Nürnberg, Germany

    looks like it was fixed. nice!

  • Status changed to Fixed about 2 months ago
  • 🇺🇸United States smustgrave

    Rock on. There is a setting to the focus call but not supported by many browsers yet.

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

Production build 0.71.5 2024