MOBILE-3833 core: Fix empty split views updates
parent
ce7880afc3
commit
4cdcb23d97
|
@ -123,7 +123,13 @@ export class CoreListItemsManager<
|
|||
*
|
||||
* @param item Item.
|
||||
*/
|
||||
async select(item: Item): Promise<void> {
|
||||
async select(item: Item | null): Promise<void> {
|
||||
if (!item) {
|
||||
await this.navigateToIndex({ reset: this.resetNavigation() });
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await this.navigateToItem(item, { reset: this.resetNavigation() });
|
||||
}
|
||||
|
||||
|
@ -174,17 +180,9 @@ export class CoreListItemsManager<
|
|||
protected updateSelectedItem(route: ActivatedRouteSnapshot | null = null): void {
|
||||
super.updateSelectedItem(route);
|
||||
|
||||
if (CoreScreen.isMobile || this.selectedItem !== null || !this.splitView || this.splitView.isNested) {
|
||||
return;
|
||||
}
|
||||
const selectDefault = CoreScreen.isTablet && this.selectedItem === null && this.splitView && !this.splitView.isNested;
|
||||
|
||||
const defaultItem = this.getDefaultItem();
|
||||
|
||||
if (!defaultItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.select(defaultItem);
|
||||
this.select(selectDefault ? this.getDefaultItem() : this.selectedItem);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -119,6 +119,34 @@ export abstract class CoreRoutedItemsManager<
|
|||
await CoreNavigator.navigate(pathPrefix + itemPath, { params, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to the index page.
|
||||
*
|
||||
* @param options Navigation options.
|
||||
*/
|
||||
protected async navigateToIndex(
|
||||
options: Pick<CoreNavigationOptions, 'reset' | 'replace' | 'animationDirection'> = {},
|
||||
): Promise<void> {
|
||||
// Get current route in the page.
|
||||
const route = this.getCurrentPageRoute();
|
||||
|
||||
if (route === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the current page is already the index, do nothing.
|
||||
const selectedItemPath = this.getSelectedItemPath(route.snapshot);
|
||||
|
||||
if (selectedItemPath === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Navigate to index.
|
||||
const indexPath = selectedItemPath ? selectedItemPath.split('/').fill('../').join('') : '';
|
||||
|
||||
await CoreNavigator.navigate(indexPath, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue