universalviewer
universalviewer copied to clipboard
Viewer grabs browser focus when manifest loads
There doesn't seem to be a config option to turn this off, and I can't seem to find it in a quick perusal of the codebase. Is there any way to turn this off? Sometimes a user wants to click a button at the bottom of the view before the viewer loads, tries to click, and then the viewer loads and scrolls them back up.
Auto focusing was added as an accessibility feature for the BL I think.
Could you try commenting out this:
https://github.com/UniversalViewer/universalviewer/blob/dev/src/modules/uv-shared-module/BaseExtension.ts#L560
and see if that makes a difference? If so, a root-level config option stealFocus (boolean) could be a good idea.
@edsilv Sorry for how long this took. Commenting out the
$('[tabindex=1]').focus();
didn't fix it.
We have the same issue which we are starting to get complaints from users about unfortunately.
https://github.com/UniversalViewer/universalviewer/issues/304
https://www.llgc.org.uk/en/collections/activities/exhibitions/words-of-war/ https://www.llgc.org.uk/blog https://www.llgc.org.uk/blog/?paged=2
It doesn't seem to be happening on the embeds test page:
http://universalviewer.io/examples/embeds.html
I notice @LlGC-szw that you're using v1.5.32 - perhaps if you sync your fork with the latest version (1.7.32) and give it another try it might fix it? The latest code is on the dev branch. Here's a guide for keeping your fork up to date:
https://github.com/UniversalViewer/universalviewer/wiki/Updating-your-Fork
Hi Ed, I've tested on the latest build (1.7.32) and the same thing is happening as in Sara's examples. I've tested locally on my machine in case it's anything to do with our CMS and still get the same result. The only difference between your example and mine was that I put a wall of text ahead of the first instance and between each instance of the viewer.

I've updated the embeds.html to include text between UV instances, still not seeing the jumping...
Here's the page Dylan is referring to. It's a plain html file with viewers embedded at the end of the page.
If the viewer is placed with sufficient text above it so the user would have to scroll down the page to see the viewer then the jumping will occur.
http://www.llgc.org.uk/primo/scroll.php
I've also copied your file over to our server but repeated the first paragraph several times so you can see the jumping there also:
http://www.llgc.org.uk/primo/embed.html
I'm getting mixed content errors (https to http) for that embed.html
Hi Ed thanks for having a look, I've updated Sara's example for https. There should only be warnings for some images being displayed in http. But am still getting the page scrolling down after page load. I've tested it on an external connection in case it was anything to do with our proxy but the same issue is replicated.
https://www.llgc.org.uk/blog/?p=11111
I think this might be OSD stealing focus.
@edsilv , we are also having troubles with this issue. The page scrolls to the latest Universal Viewer on the page. Was there a solution to this issue? Or is there a work around?
There is a config option: https://github.com/UniversalViewer/universalviewer/search?q=allowStealFocus
"options": {
"allowStealFocus": false
}
Can you check if that is set to true?
Yes, we tried setting it to false (and also tried true) but it does not change the issue

I think there are some extra places where we should also check for the allowStealFocus that might be causing the issue.
If there is a dialog that opens by default (click through), the button will be focussed: https://github.com/UniversalViewer/universalviewer/blob/67ada49f6d866a51ab173d7166f6ddf04fffb471/src/content-handlers/iiif/modules/uv-shared-module/Dialogue.ts#L151-L166
Does the IIIF you are working with show a dialog?
edit: Are you able to tell which HTML element is focused when it scrolls down (On Chrome you may be able to press shift to see an outline)
It does not open a dialog, but when I tab to check where my focus is, it is in the left sidebar.

Ah, found it.
https://github.com/UniversalViewer/universalviewer/blob/main/src/content-handlers/iiif/modules/uv-contentleftpanel-module/ThumbsView.tsx#L81-L86
Looks like this is where it's scrolling. Can replicate on https://universalviewer.dev if you scroll down a bit and refresh the page.
cc @edsilv
@stephenwf @edsilv , Would there be a solution to this issue? 🙏
Hi @carolineboeykens
I'm about to start a UV fixes sprint. Will see if I can add the allowStealFocus config option to the thumbnails section @stephenwf has linked to.
That should be fixed now: https://www.universalviewer.dev/
I haven't done a new release yet, but the fix is on main if you want to build it yourself.
scrollIntoView scrolls all parent containers. I switched to scrollTo which only scrolls a specific container: https://github.com/UniversalViewer/universalviewer/blob/main/src/content-handlers/iiif/modules/uv-contentleftpanel-module/ThumbsView.tsx#L80-L88
no need to add allowStealFocus
Thank you!
@edsilv , it works fine! Do you know when this will be released? 🙏