Skip to content

Conversation

@revolunet
Copy link

basic implementation that go to prev/next issue based on the current url issue number

it use prev/next arrows keys

basic implementation that go to prev/next issue based on url issue number

use prev/next keyboard keys
@DrewML
Copy link
Contributor

DrewML commented Sep 13, 2016

Taking a quick look at the code, I don't think this is going to work the way you expect.

const uri = location.href.replace(/\/issues\/(\d+)\/?$/, function(match, current) {

The sequential IDs in GitHub increment based on both an issue and a PR, so there are gaps where you'll be jumping between issues and PRs.

This becomes more problematic because when you hit /issues/123 and 123 is a PR number, GitHub will redirect to /pulls/123. Because the regex (/\/issues\/(\d+)\/?$/) is looking for /issues/ in the URI, I assume it's going to lead to an inconsistent situation, where the shortcuts work on some pages, but then stop working once you hit an issue.

Would you be able to test this behavior out (if you haven't already)?

window.enableIssuesPrevNext = (() => {
const handler = ({keyCode, target}) => {
// just go to prev/next issue based on current issue number
if ((keyCode === PREV_KEYCODE || keyCode === NEXT_KEYCODE) && target.nodeName !== 'INPUT' && target.nodeName !== 'TEXTAREA') {
Copy link
Contributor

@DrewML DrewML Sep 13, 2016

Choose a reason for hiding this comment

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

This check may be too generic. For users that prefer to navigate with keyboard shortcuts instead of the mouse, those keys are used to scroll left/right. (this was suggested in #152 by other contributors, though, so maybe I'm in the minority).

@revolunet
Copy link
Author

Thanks for all the instructive feedback 👍

Except using github API i have no idea how to handle that PR number issue

@DrewML
Copy link
Contributor

DrewML commented Sep 13, 2016

Thanks for all the instructive feedback

No problem - appreciate you contributing :)

Except using github API i have no idea how to handle that PR number issue

Yeah. That PR/Issue problem makes this task super difficult. There is also the issue of not being able to persist sort/search query that was discussed here. GitHub has things setup in such a way that make accomplishing this in the best way near impossible.

@revolunet revolunet closed this Sep 14, 2016
@sindresorhus
Copy link
Member

The sequential IDs in GitHub increment based on both an issue and a PR, so there are gaps where you'll be jumping between issues and PRs.

Not just that. You'll also run into the problem of deleted issues which goes to 404. Usually from spam or abusive issues.

I think the new GraphQL API would make this possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants