Trap lightbox, and fix and bug in umbfocuslock found under test#12787
Trap lightbox, and fix and bug in umbfocuslock found under test#12787rammi987 wants to merge 3 commits intoumbraco:contribfrom
Conversation
|
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:
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" |
There was a problem hiding this comment.
Does it need the ng-attr- part here?
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
But this should work as well: https://github.com/umbraco/Umbraco-CMS/blob/v10/contrib/src/Umbraco.Web.UI.Client/src/views/components/overlays/umb-overlay.html#L5 (default is true).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I guess you mean umb-focus-lock 😉
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Could it use the following instead?
if(focusableElements.some(elm => elm == document.activeElement)) {
There was a problem hiding this comment.
@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
| // 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) { |
There was a problem hiding this comment.
I think if (focusableElements.includes(document.activeElement) === false would work as well?
rammi987
left a comment
There was a problem hiding this comment.
@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 :)
|
@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 🙈 |
|
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 🙂 |
|
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 |
|
Sorry, missed this comment @rammi987 but thanks for the update to let me know 🙂 Much appreciate your efforts to progress it, though. Thanks, |

Prerequisites
umbraco/Umbraco-CMS.Accessibility.Issues#61
Description
Steps to replicate:
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.