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

List PgDn / PgUp semantics are inverted when hitting the list item boundary conditions #580

Closed
berrange opened this issue Mar 15, 2021 · 1 comment · Fixed by #581
Closed

Comments

@berrange
Copy link
Contributor

When there are further items off screen, PgDn will move down to select the next set of items, but when there are no further items, PgDn will do the inverse and select the first item, instead of selecting the last item.

Similarly, when there are previous items off screen, PgUp will move up to select the previous set of items, but when there are no further items, PgUp will do the inverse and select the last item, instead of selecting the first item

This gets particularly confusing in the common case where all items fit on the screen - PgDn always selects the first item, while PgUp always selects the last item - which is opposite of what people are expecting.

berrange added a commit to berrange/tview that referenced this issue Mar 15, 2021
Consider a list with 5 items, and the currentItem index is 2, and
all items fit on the screen without scrolling.

KeyPgDn will set currentItem to 7 which is out of bounds, and
gets wrapped around to 0.

KeyPgUp will set currentItem to -3 which is out of bounds, and
gets wrapped around to 4.

Thus PgDn selects the first item, while PgUp selects the last item,
which is the opposite of expected behaviour for these keys. Fix
this by clamping currentItem to the boundaries in the key handler.

Fixes: rivo#580
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
@rivo rivo closed this as completed in #581 Apr 26, 2021
@rivo
Copy link
Owner

rivo commented Apr 26, 2021

Makes sense. Thanks.

DomenicoSola added a commit to DomenicoSola/tview that referenced this issue Oct 19, 2022
Consider a list with 5 items, and the currentItem index is 2, and
all items fit on the screen without scrolling.

KeyPgDn will set currentItem to 7 which is out of bounds, and
gets wrapped around to 0.

KeyPgUp will set currentItem to -3 which is out of bounds, and
gets wrapped around to 4.

Thus PgDn selects the first item, while PgUp selects the last item,
which is the opposite of expected behaviour for these keys. Fix
this by clamping currentItem to the boundaries in the key handler.

Fixes: rivo/tview#580
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
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 a pull request may close this issue.

2 participants