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

ScrollTo API on List widget #2195

Merged
merged 8 commits into from Apr 30, 2021

Conversation

AnkushJadhav
Copy link
Contributor

@AnkushJadhav AnkushJadhav commented Apr 25, 2021

Description:

Exposed a ScrollTo API that scrolls a List widget and sets the focus on the ListItem represented by the id given to the API.

Fixes #2105

Checklist:

  • Tests included.

  • Lint and formatter run with no errors.

  • Tests all pass.

  • Public APIs match existing style.

Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

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

Nick work. Just a little suggestion to simplify a math operation.

widget/list.go Show resolved Hide resolved
Co-authored-by: Jacob <Jacalz@users.noreply.github.com>
Jacalz
Jacalz previously approved these changes Apr 25, 2021
Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

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

Thanks. This looks good to me 👍

Just one little note. This seems to incorrectly mention fixing #1892 which is specific to the table widget. Did you plan to add in a fix for that as well?

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

An api “ScrollTo” should not change selection, there is a separate API that does that already.

Also the initial issue requests ScrollToBottom, would that and ScrollToTop be useful too?

@AnkushJadhav
Copy link
Contributor Author

Thanks. This looks good to me 👍

Just one little note. This seems to incorrectly mention fixing #1892 which is specific to the table widget. Did you plan to add in a fix for that as well?

@Jacalz No, I think I added that one incorrectly. Not sure what I was thinking. Updated the PR description.

@AnkushJadhav
Copy link
Contributor Author

An api “ScrollTo” should not change selection, there is a separate API that does that already.

Also the initial issue requests ScrollToBottom, would that and ScrollToTop be useful too?

@andydotxyz The "ScrollTo" API does not change the selection. It simply scrolls to the item provided to it. Any selection made on the list remains intact.
A ScrollToTop and ScrollToBottom seemed more like utility functions to me, that don't add much value. The developer can easily implement these functions themselves by using the ScrollTo API. Your thoughts?

@AnkushJadhav
Copy link
Contributor Author

@andydotxyz The existing Select API modified the selection and also scrolled to the selection. While the new ScrollTo API ONLY scrolls to the item. Since both these APIs have a "scroll to item" kind of logic in them, so extracted that logic into a common helper function.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

I understand now - apologies that I misread the code.
I was confused by the use of the word "Focus" when you were just meaning scroll to make visible. Can you please update the method name so it does not imply focus change.

widget/list.go Outdated Show resolved Hide resolved
@andydotxyz
Copy link
Member

@andydotxyz The existing Select API modified the selection and also scrolled to the selection. While the new ScrollTo API ONLY scrolls to the item. Since both these APIs have a "scroll to item" kind of logic in them, so extracted that logic into a common helper function.

You're quite right, apologies. The method name tripped me up, can you find a better name?

@andydotxyz
Copy link
Member

A ScrollToTop and ScrollToBottom seemed more like utility functions to me, that don't add much value

I was just suggesting it because those were added to container.Scroll at the request of previous users.

@AnkushJadhav
Copy link
Contributor Author

A ScrollToTop and ScrollToBottom seemed more like utility functions to me, that don't add much value

I was just suggesting it because those were added to container.Scroll at the request of previous users.

Oh, then it makes sense to have them for consistency. Updated the PR.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

I think there is an off-by-one in there.

widget/list.go Show resolved Hide resolved
andydotxyz
andydotxyz previously approved these changes Apr 28, 2021
Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

Great, thanks

@andydotxyz
Copy link
Member

It seems that GitHub has a policy or blocking first-time contributor CI. I have asked it to progress now.
As a result there are some staticcheck errors to fix, sorry!

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

I am so sorry for forgetting about this (my head was in bug fixing) but each of the new methods needs the following comment added:

//
// Since: 2.1

@AnkushJadhav
Copy link
Contributor Author

@andydotxyz Thanks for pointing that out. Sorry, this is my first time on a big open source project, so still learning all the nitty-gritty.

@andydotxyz
Copy link
Member

@andydotxyz Thanks for pointing that out. Sorry, this is my first time on a big open source project, so still learning all the nitty-gritty.

Don't apologise, we have a lot of processes to keep the API need and consistent. There is a load written down at https://github.com/fyne-io/fyne/wiki/Contributing

@andydotxyz andydotxyz merged commit ee9b834 into fyne-io:develop Apr 30, 2021
@AnkushJadhav AnkushJadhav deleted the feature/list-scroll-api branch May 3, 2021 14:31
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.

None yet

3 participants