Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue 923 allow search results paging on single page #1053

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

jamesmisson
Copy link
Contributor

Fixes a bug identified in Issue 923 that disabled the next/previous search results buttons when the manifest had a single canvas. #923

Copy link

vercel bot commented Jul 4, 2024

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 Jul 8, 2024 4:12pm

@demiankatz
Copy link
Contributor

@jamesmisson, I re-targeted this from the main branch to the dev branch, since new code should get merged to dev first.

Copy link
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.

See below for some thoughts and questions; this is based on a fairly shallow look at the code, so apologies if I'm missing any important details! :-)

@@ -380,6 +381,10 @@ export class FooterPanel extends BaseFooterPanel<
return true;
}

// if only one canvas then allow clicking next result
if (totalCanvases === 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of comments on this:

1.) I'm wondering if this special case is masking a different/larger bug. I'm not sure why we need to account for having just one canvas differently. If there's only one canvas, then shouldn't currentCanvasIndex equal lastSearchResultCanvasIndex? And if that's the case, how is it any different from being on the last page of a multi-page result? If that's not the case, then maybe there's a bug related to determining the current index, or in one of the other comparisons, and we'd be better off fixing that underlying problem instead of adding a workaround at the end.

2.) If we do indeed need to keep this code as-is, some minor stylistic changes are needed -- return true is missing a semi-colon, and the closing brace needs to be dropped to the next line. I'm guessing that perhaps a couple of characters were accidentally deleted here, but Javascript is tolerant enough that it works anyway. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look Demian. This did cross my mind, but currently the only logic that activates the next button in the first instance is the final return statement of this method (now line 388). The block above it is relevant only when an annotation is 'current' (after 'next' is pressed for the first time), and then it's checking that it is neither the last page or the last annotation. So my change is essentially just adding another condition to check for along with line 388. This is hard to explain! But we can discuss on the next UV call.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see -- but I still wonder if there's a more general solution to this problem. Is it possible that there's another edge case involving (<OpenSeadragonExtension>this.extension).currentAnnotationRect that isn't being properly taken into account? I would think that if there is no current rectangle, but there are highlighted search results, we would want to allow the next button to be active. Additionally, if there is only one canvas but the user has navigated to the last highlighted search result, we would NOT want the next button to be active, but I think with this current code it will never get disabled.

We should also double check that any changes we make to the "next" logic do not have matching bugs in the "previous" logic.

As you say, we can discuss further on the call -- this logic is definitely a bit hard to wrap one's head around!

Copy link
Contributor Author

@jamesmisson jamesmisson Jul 8, 2024

Choose a reason for hiding this comment

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

The more streamlined solution worked so I've edited the PR. Thanks Demian!

Copy link
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!

@demiankatz
Copy link
Contributor

I've approved this and added it to the community board. I think it can probably be merged, but I'll wait until we have clarity out of steering group before I do anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In testing
Development

Successfully merging this pull request may close these issues.

None yet

2 participants