Skip to content

Autoclose left panel on thumbnail or treenode select#1325

Closed
jamesmisson wants to merge 14 commits into
UniversalViewer:devfrom
jamesmisson:autoclose-mobile-thumbnails
Closed

Autoclose left panel on thumbnail or treenode select#1325
jamesmisson wants to merge 14 commits into
UniversalViewer:devfrom
jamesmisson:autoclose-mobile-thumbnails

Conversation

@jamesmisson

Copy link
Copy Markdown
Contributor

Part of #938

CSS is still in progress, this is for functionality only.

This adds 2 event subscriptions so that the left panel closes when a thumbnail or index tree node is selected in mobile view.

the isMobileMetric() counts both 'sm' and 'md' sizes as 'mobile'.

@vercel

vercel Bot commented Mar 4, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
universalviewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 1:22pm

@demiankatz demiankatz left a comment

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.

Thanks, @jamesmisson -- this makes sense to me and seems to work reasonably well. See below for some very nitpicky suggestions just focused on making the PR as clean as possible.

Beyond that, a couple of other comments:

1.) This is of unquestionable value at the small size. I think the medium size is debatable. In the ideal world, I would think that the metric for auto-closing the control might be whether the panel is initially visible or not -- i.e., if you need to explicitly open the panel, then it makes sense for it to close when you pick a thumbnail; if it was initially open by default, it feels a little weird if it closes when you click a thumbnail. If there's no easy practical way to implement that, I can live with what we have... and maybe that is how it behaves (I didn't have time to dig deeply into initial behavior at all sizes).

2.) At one point during my testing, I ended up with the viewer in a weird state where the center panel was very short, and the maroon-colored background area was showing between the center panel and the footer. I'm not sure how I got there, but it probably involved a lot of browser resizing, etc. I'm not going to worry about it too much right now since things are in flux, but we'll want to watch for this bad state as we move forward in case it's a symptom of a real problem that we need to worry about.

Comment thread src/content-handlers/iiif/modules/uv-shared-module/RightPanel.ts Outdated
Comment thread src/content-handlers/iiif/modules/uv-shared-module/css/right-panel.less Outdated
Comment thread src/content-handlers/iiif/modules/uv-shared-module/css/styles.less Outdated
@jamesmisson

jamesmisson commented Mar 5, 2025

Copy link
Copy Markdown
Contributor Author

Thanks @demiankatz , I've done those bits of clean-up.

I've also changed it so that it only auto-closes in 'sm' size for now. I agree that ultimately we want it to auto-close if its initial state is closed. I tried something that should work, but it doesn't work in this branch yet as I think determining the open/closed state on initiation might still be up in the air for mobile. Here's the method I used (partly for my own reference if we implement it later):

  • leftPanel.ts currently creates a new boolean 'shouldOpenPanel' on inititiation:

` init(): void {
super.init();

const shouldOpenPanel: boolean = Bools.getBool(
  this.extension.getSettings().leftPanelOpen,
  this.options.panelOpen
);

if (shouldOpenPanel) {
  this.toggle(true);
}

}`

  • move shouldOpenPanel out of the init function so that its accessible as a property on leftPanel;
  • Check for this in the event subscriptions in contentLeftPanel like so:
    this.extensionHost.subscribe(IIIFEvents.TREE_NODE_SELECTED, () => { if (this.shouldOpenPanel) { this.toggle(true) } })

It would be useful if we can talk about the initial open/closed state with @LlGC-jop before implementing this.

@jamesmisson

jamesmisson commented Mar 5, 2025

Copy link
Copy Markdown
Contributor Author

Getting the initial metric and making it a property of the baseExpandPanel in order to determine autoclosing is proving a bit tricky. The _updateMetric() method on BaseExtension supplies the current metric on init, but for some reason it's got a 1ms delay on it, so it's happening after the baseExpandPanels are initiating, so checking for 'sm' at higher class levels is giving 'undefined'. Will return to this tomorrow.

if checking the metric value from the panels worked, then putting this either on leftPanel or contentLeftPanel would cover the conditions for setting the initial state, taking into account the last user state of the panel, the config on init, and the size on init:

this.shouldOpenPanel = Bools.getBool( this.extension.getSettings().leftPanelOpen, this.options.panelOpen && this.extension.metric != 'sm', )

if (this.shouldOpenPanel) { this.toggle(true); }

(this is probably why the 'isMobile()' on the baseExtension exists, as it checks this.metric there rather than checking this.extension.metric.)

@demiankatz

Copy link
Copy Markdown
Contributor

@jamesmisson, I wonder if this is a situation where emitting an event might help... though that gets messy pretty quickly.

@demiankatz demiankatz left a comment

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.

See below for a couple of small thoughts/suggestions.

Comment thread src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts
Comment thread src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts Outdated

@demiankatz demiankatz left a comment

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.

Thanks, @jamesmisson -- looking good, but one small detail in need of attention.

Comment thread src/content-handlers/iiif/modules/uv-shared-module/IExtension.ts Outdated
@demiankatz

Copy link
Copy Markdown
Contributor

Thanks, @jamesmisson -- everything looks good now. I'm not going to approve this yet since I expect we may not want to merge this PR as-is. I'll wait until our conversation with @LlGC-jop tomorrow to figure out which PRs are actually destined for merging to dev and which will be closed as partial work in progress.

@demiankatz

Copy link
Copy Markdown
Contributor

Superseded by #1343.

@demiankatz demiankatz closed this Mar 14, 2025
demiankatz pushed a commit that referenced this pull request Mar 26, 2025
This commit makes side panel functionality fully accessible in the mobile view, where critical features were previously unreachable.

It makes responsive behavior more CSS-based and less dependent on Javascript logic.

It incorporates work from #1321, #1325, #1330, #1333 and #1337.
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