universalviewer icon indicating copy to clipboard operation
universalviewer copied to clipboard

Viewer grabs browser focus when manifest loads

Open tpendragon opened this issue 9 years ago • 19 comments

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.

tpendragon avatar Mar 15 '16 17:03 tpendragon

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 avatar Mar 23 '16 16:03 edsilv

@edsilv Sorry for how long this took. Commenting out the

$('[tabindex=1]').focus();

didn't fix it.

tpendragon avatar Apr 26 '16 15:04 tpendragon

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

LlGC-szw avatar Jun 01 '16 11:06 LlGC-szw

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

edsilv avatar Jun 01 '16 13:06 edsilv

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.

screenshot from 2016-06-01 15 59 54

LlGC-dwj avatar Jun 01 '16 15:06 LlGC-dwj

I've updated the embeds.html to include text between UV instances, still not seeing the jumping...

edsilv avatar Jun 01 '16 16:06 edsilv

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.

LlGC-szw avatar Jun 02 '16 08:06 LlGC-szw

http://www.llgc.org.uk/primo/scroll.php

LlGC-szw avatar Jun 02 '16 08:06 LlGC-szw

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

LlGC-szw avatar Jun 02 '16 08:06 LlGC-szw

I'm getting mixed content errors (https to http) for that embed.html

edsilv avatar Jun 02 '16 13:06 edsilv

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.

LlGC-dwj avatar Jun 02 '16 13:06 LlGC-dwj

https://www.llgc.org.uk/blog/?p=11111

LlGC-dwj avatar Sep 12 '16 13:09 LlGC-dwj

I think this might be OSD stealing focus.

edsilv avatar Sep 12 '16 13:09 edsilv

@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?

carolineboeykens avatar Jun 28 '22 10:06 carolineboeykens

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?

stephenwf avatar Jun 28 '22 10:06 stephenwf

Yes, we tried setting it to false (and also tried true) but it does not change the issue

Screenshot 2022-06-28 at 12 17 43

carolineboeykens avatar Jun 28 '22 10:06 carolineboeykens

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)

stephenwf avatar Jun 28 '22 10:06 stephenwf

It does not open a dialog, but when I tab to check where my focus is, it is in the left sidebar.

Screenshot 2022-06-28 at 12 22 55

carolineboeykens avatar Jun 28 '22 10:06 carolineboeykens

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 avatar Jun 28 '22 10:06 stephenwf

@stephenwf @edsilv , Would there be a solution to this issue? 🙏

carolineboeykens avatar Sep 26 '22 10:09 carolineboeykens

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.

edsilv avatar Sep 26 '22 10:09 edsilv

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.

edsilv avatar Sep 26 '22 16:09 edsilv

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

edsilv avatar Sep 26 '22 16:09 edsilv

Thank you!

carolineboeykens avatar Sep 27 '22 06:09 carolineboeykens

@edsilv , it works fine! Do you know when this will be released? 🙏

carolineboeykens avatar Oct 12 '22 11:10 carolineboeykens