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

My Site: fix iPad default selected row #18118

Merged
merged 8 commits into from
Mar 15, 2022
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* [*] Improves the error message shown when trying to create a new site with non-English characters in the domain name [https://github.com/wordpress-mobile/WordPress-iOS/pull/17985]
* [*] Quick Start: updated the design for the Quick Start cell on My Site [#18095]
* [*] Reader: Fixed a bug where comment replies are misplaced after its parent comment is moderated [#18094]
* [*] iPad: Fixed a bug where the current displayed section wasn't selected on the menu [#18118]

19.4
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ extension BlogDetailsSubsection {
return .domainCredit
case .quickStart:
return .quickStart
case .stats, .activity:
return .general
case .stats, .activity, .jetpackSettings:
return .jetpack
case .pages, .posts, .media, .comments:
return .publish
case .themes, .customize:
return .personalize
case .sharing, .people, .plugins:
return .configure
case .jetpackSettings:
return .jetpack
case .home:
return .home
@unknown default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ - (NSIndexPath *)indexPathForSubsection:(BlogDetailsSubsection)subsection
case BlogDetailsSubsectionQuickStart:
return [NSIndexPath indexPathForRow:0 inSection:section];
case BlogDetailsSubsectionStats:
return [self shouldShowQuickStartChecklist] ? [NSIndexPath indexPathForRow:1 inSection:section] : [NSIndexPath indexPathForRow:0 inSection:section];
return [NSIndexPath indexPathForRow:0 inSection:section];
case BlogDetailsSubsectionActivity:
return [NSIndexPath indexPathForRow:0 inSection:section];
case BlogDetailsSubsectionJetpackSettings:
Expand Down Expand Up @@ -598,7 +598,7 @@ - (NSIndexPath *)restorableSelectedIndexPath
{
if (!_restorableSelectedIndexPath) {
// If nil, default to stats subsection.
BlogDetailsSubsection subsection = BlogDetailsSubsectionStats;
BlogDetailsSubsection subsection = [self shouldShowDashboard] ? BlogDetailsSubsectionHome : BlogDetailsSubsectionStats;
self.selectedSectionCategory = [self sectionCategoryWithSubsection:subsection];
NSUInteger section = [self findSectionIndexWithSections:self.tableSections category:self.selectedSectionCategory];
_restorableSelectedIndexPath = [NSIndexPath indexPathForRow:0 inSection:section];
Expand All @@ -612,6 +612,7 @@ - (void)setRestorableSelectedIndexPath:(NSIndexPath *)restorableSelectedIndexPat
if (restorableSelectedIndexPath != nil && restorableSelectedIndexPath.section < [self.tableSections count]) {
BlogDetailsSection *section = [self.tableSections objectAtIndex:restorableSelectedIndexPath.section];
switch (section.category) {
case BlogDetailsSectionCategoryQuickAction:
case BlogDetailsSectionCategoryQuickStart:
case BlogDetailsSectionCategoryDomainCredit: {
_restorableSelectedIndexPath = nil;
Expand Down Expand Up @@ -687,9 +688,11 @@ - (void)reloadTableViewPreservingSelection

// For QuickStart and Use Domain cases we want to select the first row on the next available section
switch (section.category) {
case BlogDetailsSectionCategoryQuickAction:
case BlogDetailsSectionCategoryQuickStart:
case BlogDetailsSectionCategoryDomainCredit: {
BlogDetailsSectionCategory category = [self sectionCategoryWithSubsection:BlogDetailsSubsectionStats];
BlogDetailsSubsection subsection = [self shouldShowDashboard] ? BlogDetailsSubsectionHome : BlogDetailsSubsectionStats;
BlogDetailsSectionCategory category = [self sectionCategoryWithSubsection:subsection];
sectionIndex = [self findSectionIndexWithSections:self.tableSections category:category];
}
break;
Expand All @@ -705,10 +708,13 @@ - (void)reloadTableViewPreservingSelection
self.restorableSelectedIndexPath.row < [self.tableView numberOfRowsInSection:self.restorableSelectedIndexPath.section];
if (isValidIndexPath && ![self splitViewControllerIsHorizontallyCompact]) {
// And finally we'll reselect the selected row, if there is one
NSLog(@"$$ index path row %d %d", self.restorableSelectedIndexPath.row, self.restorableSelectedIndexPath.section);

[self.tableView selectRowAtIndexPath:self.restorableSelectedIndexPath
animated:NO
scrollPosition:[self optimumScrollPositionForIndexPath:self.restorableSelectedIndexPath]];
} else {
NSLog(@"$$ NSNotFound %d", self.selectedSectionCategory);
}
}

Expand Down Expand Up @@ -1088,6 +1094,8 @@ - (void)showInitialDetailsForBlog
return;
}

self.restorableSelectedIndexPath = nil;

if ([self shouldShowDashboard]) {
[self showDetailViewForSubsection:BlogDetailsSubsectionHome];
} else {
Expand Down