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

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,18 @@ export class FooterPanel extends BaseFooterPanel<
const currentCanvasIndex: number = this.extension.helper.canvasIndex;
const lastSearchResultCanvasIndex: number = this.getLastSearchResultCanvasIndex();
const currentSearchResultRectIndex: number = this.getCurrentSearchResultRectIndex();
const totalCanvases: number = this.extension.helper.getTotalCanvases();

// if zoom to search result is enabled and there is a highlighted search result.
if (
this.isZoomToSearchResultEnabled() &&
(<OpenSeadragonExtension>this.extension).currentAnnotationRect
) {
if (currentCanvasIndex > lastSearchResultCanvasIndex) {
if (currentCanvasIndex > lastSearchResultCanvasIndex) { //if you've moved past final result page
return false;
} else if (currentCanvasIndex === lastSearchResultCanvasIndex) {
} else if (currentCanvasIndex === lastSearchResultCanvasIndex) { // if you're on the final result page
if (
currentSearchResultRectIndex === this.getLastSearchResultRectIndex()
currentSearchResultRectIndex === this.getLastSearchResultRectIndex() //and you're on the last result
) {
return false;
}
Expand All @@ -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!

return true}

return currentCanvasIndex < lastSearchResultCanvasIndex;
}

Expand Down
Loading