Skip to content

Trap lightbox, and fix and bug in umbfocuslock found under test#12787

Closed
rammi987 wants to merge 3 commits intoumbraco:contribfrom
rammi987:Accessibility/61
Closed

Trap lightbox, and fix and bug in umbfocuslock found under test#12787
rammi987 wants to merge 3 commits intoumbraco:contribfrom
rammi987:Accessibility/61

Conversation

@rammi987
Copy link
Copy Markdown
Contributor

@rammi987 rammi987 commented Aug 5, 2022

Prerequisites

umbraco/Umbraco-CMS.Accessibility.Issues#61

Description

Steps to replicate:

  1. Go To packages tab
  2. Open a package (e.g. Umbraco forms)
  3. Scroll to bottom of the page and open the image modal

At the package details, can you at the bottom view some images, where if you tabbed around you ended outside of the ligthbox.
I have added the umb-focus-lock to the ligthbox, and now focus is trapped.

Doing my test I saw if you opened up the lightbox, go next on the images until the last (so the next arrow disappere) and tab to move focus, the focus esacpe the trap. So I extended the directive. So whenever the DOM changes inside the trap, we are getting the focusableelement, but also see if current focus still is on a trapped focusabled element, if not we set the focus at new.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 5, 2022

Hi there @rammi987, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

ng-if="vm.lightbox.show"
items="vm.lightbox.items"
active-item-index="vm.lightbox.activeIndex"
ng-attr-umb-focus-lock="true"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need the ng-attr- part here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjarnef I acctuly don´t know. I put more weight on what there has done in the past. See https://github.com/umbraco/Umbraco-CMS/blob/v10/contrib/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editors.html line 5

First I did this PR based on above files:
https://github.com/umbraco/Umbraco-CMS/blob/v10/contrib/src/Umbraco.Cms.StaticAssets/umbraco/UmbracoBackOffice/Default.cshtml line 91

And now this PR, so it was more an alignment, maybe is something to do white the ng-attr tell to run expresstion and just umb-focus-lock would bee a binding to the Angular directive scope

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I only think it makes a difference to ensure to binding is ready, e.g. style vs ng-style. I recall originalen IE had issues when using expression directly in style attribute.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a small test. It dons´t matter if you type in ng-attr-umb-focus-trap or just umb-focus-trap. Both work and fix the modal trap issue. So it is more what will be more likeable to look at?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you mean umb-focus-lock 😉

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea - need a Redbull


// When an element is remove or become not focusable, but focus is on it,
// we need to ensure a now focus inside the trap, else the focus can escape the trap.
if (focusableElements.filter(elm => elm == document.activeElement).length === 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it use the following instead?

if(focusableElements.some(elm => elm == document.activeElement)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjarnef I have made a slighty change to the line, instead of filter or some. I used the IndexOf()
IndexOf is the most readable line and fasted execution time, https://www.measurethat.net/Benchmarks/Show/20458/0/some-vs-filter-vs-indexof-vs-includes1123123123

Copy link
Copy Markdown
Contributor

@bjarnef bjarnef Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I ran the test and it says includes are the fastest 😄

Screenshot_20220817-133436_Outlook

Maybe it is different result from at mobile device 😄

// When an element is remove or become not focusable, but focus is on it,
// we need to ensure a now focus inside the trap, else the focus can escape the trap.
if (focusableElements.filter(elm => elm == document.activeElement).length === 0) {
if (focusableElements.indexOf(document.activeElement) === -1) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if (focusableElements.includes(document.activeElement) === false would work as well?

Copy link
Copy Markdown
Contributor Author

@rammi987 rammi987 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjarnef I removed ng-attr-* it was unnecceary.

I did a bounche of test on IndexOf vs Includes. Well sometimes is IndexOf but most of the time and on diffenct device includes is the fastes. So to maintian good speed i´ll go with includes as my finally commit :)

@bjarnef
Copy link
Copy Markdown
Contributor

bjarnef commented Aug 17, 2022

@rammi987 if you are looking further into focus lock, I have noticed issues with it in block list configuration: #12851 (see the "after" video which open the second overlays - after close the label get focus)

From a block configuration after opening e.g. settings element type or thumbnail, it seems the label property at top steal the focus and thus scroll to top of the overlay, which is a bit annoying 🙈

@nul800sebastiaan nul800sebastiaan changed the base branch from v10/contrib to v11/contrib October 25, 2022 13:06
@nul800sebastiaan nul800sebastiaan changed the base branch from v11/contrib to contrib January 26, 2023 14:52
@emmagarland
Copy link
Copy Markdown
Collaborator

Hi @rammi987!

Just going through some of the longer running PRs, and noticed this one (it's been a while, so there are now some conflicts sorry!)

I know it was a while ago but did you need anything else for this one, or do you need any help to progress? Or will it be ready for review? Let me know if you need any help to get this one rebooted.

Thanks,

Emma 🙂

@emmagarland emmagarland self-assigned this May 23, 2023
@rammi987
Copy link
Copy Markdown
Contributor Author

Hello @emmagarland

unfortunately i think the best idea is to reject this and start over. I have seen the bug fix for the directive has been accepted by an other PR from the community.

So I think is a better idea to see what is wrong with the light box now and fix it if there is accessibility errors still, in version 12

@rammi987 rammi987 closed this May 24, 2023
@emmagarland
Copy link
Copy Markdown
Collaborator

Sorry, missed this comment @rammi987 but thanks for the update to let me know 🙂

Much appreciate your efforts to progress it, though.

Thanks,
Emma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants