Skip to content

Commit a2ddd67

Browse files
authored
Merge pull request #3264 from dpalou/MOBILE-3833
Mobile 3833
2 parents 7c8d372 + b6e08cc commit a2ddd67

File tree

8 files changed

+25
-14
lines changed

8 files changed

+25
-14
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<ion-button (click)="openBlocks()" [userTour]="userTour" [attr.aria-label]="'core.block.opendrawerblocks' | translate" color="secondary"
2-
#button>
1+
<ion-button (click)="openBlocks()" [userTour]="userTour" [attr.aria-label]="'core.block.opendrawerblocks' | translate" color="secondary">
32
<ion-icon name="fas-chevron-left" slot="icon-only" aria-hidden="true"></ion-icon>
43
</ion-button>

src/core/features/block/components/side-blocks-button/side-blocks-button.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { Component, ElementRef, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
15+
import { Component, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
1616
import { CoreCancellablePromise } from '@classes/cancellable-promise';
1717
import { CoreUserTourDirectiveOptions } from '@directives/user-tour';
1818
import { CoreUserToursAlignment, CoreUserToursSide } from '@features/usertours/services/user-tours';
@@ -33,14 +33,17 @@ export class CoreBlockSideBlocksButtonComponent implements OnInit, OnDestroy {
3333

3434
@Input() contextLevel!: string;
3535
@Input() instanceId!: number;
36-
@ViewChild('button', { read: ElementRef }) button?: ElementRef<HTMLElement>;
3736

3837
userTour: CoreUserTourDirectiveOptions = {
3938
id: 'side-blocks-button',
4039
component: CoreBlockSideBlocksTourComponent,
4140
side: CoreUserToursSide.Start,
4241
alignment: CoreUserToursAlignment.Center,
43-
getFocusedElement: nativeButton => nativeButton.shadowRoot?.children[0] as HTMLElement,
42+
getFocusedElement: nativeButton => {
43+
const innerButton = Array.from(nativeButton.shadowRoot?.children ?? []).find(child => child.tagName === 'BUTTON');
44+
45+
return innerButton as HTMLElement ?? nativeButton;
46+
},
4447
};
4548

4649
protected element: HTMLElement;

src/core/features/course/components/course-format/course-format.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<!-- Course Index button. -->
5757
<ion-fab slot="fixed" core-fab vertical="bottom" horizontal="end" *ngIf="loaded && displayCourseIndex">
5858
<ion-fab-button (click)="openCourseIndex()" [userTour]="courseIndexTour" [attr.aria-label]="'core.course.courseindex' | translate"
59-
color="secondary" #courseIndexFab>
59+
color="secondary">
6060
<ion-icon name="fas-list-ul" aria-hidden="true"></ion-icon>
6161
<span class="sr-only">{{'core.course.courseindex' | translate }}</span>
6262
</ion-fab-button>

src/core/features/course/components/course-format/course-format.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
QueryList,
2424
Type,
2525
ElementRef,
26-
ViewChild,
2726
} from '@angular/core';
2827
import { CoreDomUtils } from '@services/utils/dom';
2928
import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component';
@@ -77,7 +76,6 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
7776
@Input() moduleId?: number; // The module ID to scroll to. Must be inside the initial selected section.
7877

7978
@ViewChildren(CoreDynamicComponent) dynamicComponents?: QueryList<CoreDynamicComponent>;
80-
@ViewChild('courseIndexFab', { read: ElementRef }) courseIndexFab?: ElementRef<HTMLElement>;
8179

8280
// All the possible component classes.
8381
courseFormatComponent?: Type<unknown>;
@@ -93,7 +91,11 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
9391
component: CoreCourseCourseIndexTourComponent,
9492
side: CoreUserToursSide.Top,
9593
alignment: CoreUserToursAlignment.End,
96-
getFocusedElement: nativeButton => nativeButton.shadowRoot?.children[0] as HTMLElement,
94+
getFocusedElement: nativeButton => {
95+
const innerButton = Array.from(nativeButton.shadowRoot?.children ?? []).find(child => child.tagName === 'BUTTON');
96+
97+
return innerButton as HTMLElement ?? nativeButton;
98+
},
9799
};
98100

99101
displayCourseIndex = false;

src/core/features/course/pages/contents/contents.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon
353353
* @return Promise resolved when done.
354354
*/
355355
protected async showLoadingAndRefresh(sync = false, invalidateData = true): Promise<void> {
356-
// Save scroll position to restore it once done.
357356
this.updatingData = true;
358357
this.changeDetectorRef.detectChanges();
359358

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<core-user-avatar *ngIf="isMainScreen && siteInfo" [user]="siteInfo" class="core-bar-button-image clickable" [linkProfile]="false"
22
(ariaButtonClick)="openUserMenu($event)" [userTour]="userTour" role="button" tabindex="0"
3-
[attr.aria-label]="'core.user.useraccount' | translate" #avatar>
3+
[attr.aria-label]="'core.user.useraccount' | translate">
44
</core-user-avatar>

src/core/features/mainmenu/components/user-menu-button/user-menu-button.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
15+
import { Component, OnInit } from '@angular/core';
1616
import { CoreSiteInfo } from '@classes/site';
1717
import { CoreUserTourDirectiveOptions } from '@directives/user-tour';
1818
import { CoreUserToursAlignment, CoreUserToursSide } from '@features/usertours/services/user-tours';
@@ -44,8 +44,6 @@ export class CoreMainMenuUserButtonComponent implements OnInit {
4444
side: CoreScreen.isMobile ? CoreUserToursSide.Start : CoreUserToursSide.End,
4545
};
4646

47-
@ViewChild('avatar', { read: ElementRef }) avatar?: ElementRef<HTMLElement>;
48-
4947
constructor(protected routerOutlet: IonRouterOutlet) {
5048
const currentSite = CoreSites.getRequiredCurrentSite();
5149

src/core/features/usertours/components/user-tour/user-tour.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ export class CoreUserToursUserTourComponent implements AfterViewInit, OnDestroy
183183
* Play animation to show that the User Tour has started.
184184
*/
185185
private async playEnterAnimation(): Promise<void> {
186+
if (!('animate' in this.element)) {
187+
// Not supported, don't animate.
188+
return;
189+
}
190+
186191
const animations = [
187192
this.element.animate({ opacity: ['0', '1'] }, { duration: ANIMATION_DURATION }),
188193
this.wrapperElement.value?.animate(
@@ -198,6 +203,11 @@ export class CoreUserToursUserTourComponent implements AfterViewInit, OnDestroy
198203
* Play animation to show that the User Tour has endd.
199204
*/
200205
private async playLeaveAnimation(): Promise<void> {
206+
if (!('animate' in this.element)) {
207+
// Not supported, don't animate.
208+
return;
209+
}
210+
201211
const animations = [
202212
this.element.animate({ opacity: ['1', '0'] }, { duration: ANIMATION_DURATION }),
203213
this.wrapperElement.value?.animate(

0 commit comments

Comments
 (0)