Skip to content

bug: fix choosing an out of list bounds selecting the last entry #717

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

Merged
merged 1 commit into from
Apr 29, 2022

Conversation

ClementTsang
Copy link
Owner

@ClementTsang ClementTsang commented Apr 29, 2022

Description

A description of the change and what it does. If relevant (such as any change that modifies the UI), please provide screenshots of the change:

This is a simple bug fix that changes the behaviour of a scroll select (and column select) to only update if the updated position is within the bounds of the list (0 to the max index, inclusive). Prior to this, all the implementations but the disk implementation would just bound the change. This was both inconsistent with the disk scroll state, but also jarring since this meant a user could click on seemingly empty space but it would somehow click on the very last entry.

This change also unifies the scroll calculation function between all the scroll select functions. Ideally we get rid of the intermediary functions but that might require more refactoring than I want for this fairly simple bug fix.

The column select scroll calculation was also changed to fit this behaviour, but it does not use the same logic as the other scroll
states. What could be done in the future is a generic implementation for direction (or maybe just "increment vs. decrement") to share it all.

Issue

If applicable, what issue does this address?

Closes: #

Testing

If relevant, please state how this was tested. All changes must be tested to work:

Please also indicate which platforms were tested. All platforms directly affected by the change must be tested:

  • Windows
  • macOS
  • Linux

Checklist

If relevant, ensure the following have been met:

  • Areas your change affects have been linted using rustfmt (cargo fmt)
  • The change has been tested and doesn't appear to cause any unintended breakage
  • Documentation has been added/updated if needed (README.md, help menu, etc.)
  • The pull request passes the provided CI pipeline
  • There are no merge conflicts

This is a simple bug fix that changes the behaviour of a scroll select
(and column select) to only update if the updated position is _within_
the bounds of the list (0 to the max index, inclusive). Prior to this,
all the implementations but the disk implementation would just bound the
change. This was both inconsistent with the disk scroll state, but also
jarring since this meant a user could click on seemingly empty space but
it would somehow click on the very last entry.

This change also unifies the scroll calculation function between all the
scroll select functions. Ideally we get rid of the intermediary
functions but that might require more refactoring than I want for this
fairly simple bug fix.

The column select scroll calculation was also changed to fit this
behaviour, but it does not use the same logic as the other scroll
states. What could be done in the future is a generic implementation for
direction (or maybe just "increment vs. decrement") to share it all.
@codecov-commenter
Copy link

Codecov Report

Merging #717 (81a3fc5) into master (17dbea9) will increase coverage by 0.40%.
The diff coverage is 60.67%.

❗ Current head 81a3fc5 differs from pull request most recent head ad0aeed. Consider uploading reports for the commit ad0aeed to get more accurate results

@@            Coverage Diff             @@
##           master     #717      +/-   ##
==========================================
+ Coverage   17.14%   17.55%   +0.40%     
==========================================
  Files          52       52              
  Lines       13215    13217       +2     
==========================================
+ Hits         2266     2320      +54     
+ Misses      10949    10897      -52     
Impacted Files Coverage Δ
src/app.rs 0.04% <0.00%> (+<0.01%) ⬆️
src/canvas/widgets/cpu_graph.rs 0.00% <0.00%> (ø)
src/canvas/widgets/disk_table.rs 0.00% <0.00%> (ø)
src/canvas/widgets/process_table.rs 0.00% <0.00%> (ø)
src/canvas/widgets/temp_table.rs 0.00% <0.00%> (ø)
src/lib.rs 1.89% <0.00%> (ø)
src/app/states.rs 58.10% <96.42%> (+3.96%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17dbea9...ad0aeed. Read the comment docs.

@ClementTsang ClementTsang merged commit e393078 into master Apr 29, 2022
@ClementTsang ClementTsang deleted the fix_click_bug branch April 29, 2022 02:39
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 this pull request may close these issues.

2 participants