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

Set focused item index to zero if index is nil when updating the delegates #789

Merged
merged 2 commits into from
Jan 2, 2018

Conversation

zenangst
Copy link
Owner

@zenangst zenangst commented Jan 2, 2018

This fixes an issue that a user cannot resolve the current item at the index path when the view initially loads because it has yet to receive its initial index. The first component will be returned but if the index is zero you end up without a view.

To fix this, we simply set the index to zero but only if neither the component of item has been set.
This should comply nicely with the focus engine because it searches from the top left corner for the first view to focus.

Note
I bumped the version because I intend to do a minor release as soon as this has been merge into master.

@codecov
Copy link

codecov bot commented Jan 2, 2018

Codecov Report

Merging #789 into master will decrease coverage by 7.62%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #789      +/-   ##
==========================================
- Coverage   84.78%   77.15%   -7.63%     
==========================================
  Files         150      150              
  Lines       10364    10249     -115     
==========================================
- Hits         8787     7908     -879     
- Misses       1577     2341     +764
Flag Coverage Δ
#ios 58.32% <0%> (-24.89%) ⬇️
#osx 86.77% <ø> (ø) ⬆️
#tvos 74.42% <100%> (-8.43%) ⬇️
Impacted Files Coverage Δ
Sources/iOS/Classes/SpotsController.swift 55.92% <100%> (-9.65%) ⬇️
.../iOS/Extensions/CoreComponent+Extensions+iOS.swift 0% <0%> (-100%) ⬇️
SpotsTests/iOS/SpotsScrollViewTests.swift 0% <0%> (-100%) ⬇️
Sources/iOS/Classes/SpotsRefreshControl.swift 0% <0%> (-100%) ⬇️
SpotsTests/iOS/SpotsRefreshControlTests.swift 0% <0%> (-100%) ⬇️
SpotsTests/iOS/GridWrapperTests.swift 0% <0%> (-100%) ⬇️
...s/iOS/Extensions/UIViewController+Extensions.swift 0% <0%> (-100%) ⬇️
...otsTests/iOS/UIViewControllerExtensionsTests.swift 0% <0%> (-100%) ⬇️
SpotsTests/iOS/ComponentiOSTests.swift 0% <0%> (-98.31%) ⬇️
...ces/iOS/Extensions/Delegate+iOS+UIScrollView.swift 0% <0%> (-55.12%) ⬇️
... and 16 more

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 0c0be0a...ba397b0. Read the comment docs.

@zenangst zenangst merged commit db24911 into master Jan 2, 2018
@zenangst zenangst deleted the fix/focused-item-index-bug branch January 2, 2018 13:41
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