Skip to content

Add menu for canvas choice#1748

Draft
jamesmisson wants to merge 22 commits intoUniversalViewer:v4.4.0from
jamesmisson:choice-v2
Draft

Add menu for canvas choice#1748
jamesmisson wants to merge 22 commits intoUniversalViewer:v4.4.0from
jamesmisson:choice-v2

Conversation

@jamesmisson
Copy link
Copy Markdown
Contributor

@jamesmisson jamesmisson commented Apr 27, 2026

This adds support for manifests using 'choice' on the canvas as part of the BL's multispectral work, adding a dropdown menu to the image control buttons to switch between layers. I'll leave it in draft as there are a couple of outstanding things.

Most of the logic occurs in the openMedia function in OpenSeadragonCenterPanel, which now checks for choices and branches off into a slightly different way of handling image display.

This currently works for 1-up or 2-up views, provided the canvases all have at least one choice.

I don't think this will work in a scenario where the first of the canvas pair does not use choice and the second one does (because if a choice is detected on either, openMedia branches off into rendering choices only). I'll come back to this.

It should work if canvases have a different number of choices and at least 1 choice (though I still need to create a manifest to test this).

I've added the cookbook choice recipe to the example manifests. We're currently working on a more substantial manifest to test this.

I've used the existing dialogue component for the dropdown choice menu, but have developed it slightly to be positionable above or below its anchor.

I had some problems rebasing this onto v4.4.0 so the commits might look a bit weird. The work in progress can be seen on my original branch: https://github.com/jamesmisson/universalviewer/tree/choice

To do:

  • Create and test 'paged' manifest with different number of choices on each canvas (including not using choice)
  • At medium screen sizes, keep the image control buttons visible if the choice menu is open
  • Allow scroll-to-zoom when choice menu is open
  • Add choice menu to mobile footer
  • Make a config option for preserving choice selection over canvas changes.

I think ultimately the image adjustment dialogue (brightness etc.) should be streamlined and restyled to resemble this one.

@jamesmisson jamesmisson requested a review from demiankatz April 27, 2026 16:44
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
universalviewer Ready Ready Preview, Comment Apr 29, 2026 9:49pm

Request Review

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2026

@jamesmisson is attempting to deploy a commit to the Universal Viewer Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Thanks, @jamesmisson, this looks like it's off to a good start. See below for some questions and suggestions.

Also, a more general question: I see that you have logic to make this work in 2-up mode, but what happens if each canvas in 2-up view has a different set of choices? I'm not sure how the UI would work in that situation... but maybe that will be more clear when you provide the more complex sample manifest you alluded to in your comments.

Comment thread src/content-handlers/iiif/modules/uv-dialogues-module/ChoiceSwitchDialogue.ts Outdated
Comment thread src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts Outdated
@jamesmisson
Copy link
Copy Markdown
Contributor Author

Hi @demiankatz , thanks very much for taking a look.

I think on reflection I should rethink the 2-up view. As you say, they might have different choices; my current approach assumes there's at least some overlap in the choices and tries to merge them into one list. A more generalizable approach would be to have two sections in the choice menu, one for each canvas, if 2-up view is enabled. I'll work on that this afternoon.

@jamesmisson
Copy link
Copy Markdown
Contributor Author

Hi @demiankatz , I've made a few improvements. These mostly concern the 2-up display, which is now working across a range of choice combinations.

I've added the 'Paged choice combinations' manifest to the examples to test this. The canvas pairs test these combinations:

  • 3 choices/2 choices
  • 0 choices (i.e. one image)/2 choices
  • 3 choices/0 choices

That all seems to be working. NB the images I've used are very different sizes so the right hand canvases appear very small. Our production manifest is still in the works until the images are online.

And I've covered your suggestions:

  • clearer separation of concerns between the base component of choiceSwitchMenu and OSD-specific choiceSwitchMenu
  • removed redundant methods on those
  • refactored repeated code into indicesIncludeChoices(indices)
  • removed stray console log
  • added translations

@demiankatz
Copy link
Copy Markdown
Contributor

Thanks, @jamesmisson, I think your approach to the 2-up UI makes sense and it seems to work well for me.

Do you want me to take another look at the code now, or do you want me to wait until you've checked off more of your TODOs?

@jamesmisson
Copy link
Copy Markdown
Contributor Author

Thanks @demiankatz , I'll be working on those remaining things this week so probably best to hold off until they're done

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.

2 participants