Skip to content

issue 923 allow search results paging on single page#1053

Merged
demiankatz merged 2 commits intodevfrom
issue923
Jul 17, 2024
Merged

issue 923 allow search results paging on single page#1053
demiankatz merged 2 commits intodevfrom
issue923

Conversation

@jamesmisson
Copy link
Copy Markdown
Contributor

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

@vercel
Copy link
Copy Markdown

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

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! :-)

}

// if only one canvas then allow clicking next result
if (totalCanvases === 1) {
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.

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

@demiankatz
Copy link
Copy Markdown
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.

@demiankatz demiankatz merged commit fd024b6 into dev Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants