MOBILE-3320 core: Revert some auto-focus changes

main
Dani Palou 2021-05-13 12:00:19 +02:00
parent 1c0f7ad42e
commit e123c88214
8 changed files with 13 additions and 15 deletions

View File

@ -30,7 +30,7 @@ import { CoreUtils } from '@services/utils/utils';
}) })
export class CoreAutoFocusDirective implements AfterViewInit { export class CoreAutoFocusDirective implements AfterViewInit {
@Input('core-auto-focus') showKeyboard: boolean | string = true; @Input('core-auto-focus') autoFocus: boolean | string = true;
protected element: HTMLElement; protected element: HTMLElement;
@ -42,7 +42,7 @@ export class CoreAutoFocusDirective implements AfterViewInit {
* @inheritdoc * @inheritdoc
*/ */
ngAfterViewInit(): void { ngAfterViewInit(): void {
if (this.showKeyboard === 'nofocus') { if (CoreUtils.isFalseOrZero(this.autoFocus)) {
return; return;
} }
@ -78,8 +78,7 @@ export class CoreAutoFocusDirective implements AfterViewInit {
return; return;
} }
const showKeyboard = this.showKeyboard === '' || CoreUtils.isTrueOrOne(this.showKeyboard); CoreDomUtils.focusElement(element);
CoreDomUtils.focusElement(element, showKeyboard);
if (element != document.activeElement) { if (element != document.activeElement) {
this.setFocus(retries - 1); this.setFocus(retries - 1);

View File

@ -33,7 +33,7 @@
<ion-label class="sr-only">{{ 'core.login.username' | translate }}</ion-label> <ion-label class="sr-only">{{ 'core.login.username' | translate }}</ion-label>
<ion-input type="text" name="username" placeholder="{{ 'core.login.username' | translate }}" <ion-input type="text" name="username" placeholder="{{ 'core.login.username' | translate }}"
formControlName="username" autocapitalize="none" autocorrect="off" autocomplete="username" enterkeyhint="next" formControlName="username" autocapitalize="none" autocorrect="off" autocomplete="username" enterkeyhint="next"
required="true" core-auto-focus> required="true">
</ion-input> </ion-input>
</ion-item> </ion-item>
<ion-item *ngIf="siteChecked && !isBrowserSSO" class="ion-margin-bottom"> <ion-item *ngIf="siteChecked && !isBrowserSSO" class="ion-margin-bottom">

View File

@ -31,7 +31,7 @@
<ion-item> <ion-item>
<ion-label></ion-label> <ion-label></ion-label>
<ion-input type="text" name="value" placeholder="{{ 'core.login.usernameoremail' | translate }}" <ion-input type="text" name="value" placeholder="{{ 'core.login.usernameoremail' | translate }}"
formControlName="value" autocapitalize="none" autocorrect="off" [core-auto-focus]="showKeyboard"> formControlName="value" autocapitalize="none" autocorrect="off" [core-auto-focus]="autoFocus">
</ion-input> </ion-input>
</ion-item> </ion-item>
<ion-button type="submit" class="ion-margin" expand="block" [disabled]="!myForm.valid"> <ion-button type="submit" class="ion-margin" expand="block" [disabled]="!myForm.valid">

View File

@ -35,7 +35,7 @@ export class CoreLoginForgottenPasswordPage implements OnInit {
myForm!: FormGroup; myForm!: FormGroup;
siteUrl!: string; siteUrl!: string;
showKeyboard!: boolean; autoFocus!: boolean;
constructor( constructor(
protected formBuilder: FormBuilder, protected formBuilder: FormBuilder,
@ -55,7 +55,7 @@ export class CoreLoginForgottenPasswordPage implements OnInit {
} }
this.siteUrl = siteUrl; this.siteUrl = siteUrl;
this.showKeyboard = Platform.is('tablet'); this.autoFocus = Platform.is('tablet');
this.myForm = this.formBuilder.group({ this.myForm = this.formBuilder.group({
field: ['username', Validators.required], field: ['username', Validators.required],
value: [CoreNavigator.getRouteParam<string>('username') || '', Validators.required], value: [CoreNavigator.getRouteParam<string>('username') || '', Validators.required],

View File

@ -42,7 +42,7 @@
<core-show-password name="password"> <core-show-password name="password">
<ion-input class="core-ioninput-password" name="password" type="password" <ion-input class="core-ioninput-password" name="password" type="password"
placeholder="{{ 'core.login.password' | translate }}" formControlName="password" [clearOnEdit]="false" placeholder="{{ 'core.login.password' | translate }}" formControlName="password" [clearOnEdit]="false"
autocomplete="current-password" enterkeyhint="go" required="true" core-auto-focus> autocomplete="current-password" enterkeyhint="go" required="true">
</ion-input> </ion-input>
</core-show-password> </core-show-password>
</ion-item> </ion-item>

View File

@ -26,7 +26,7 @@
<h2>{{ 'core.login.siteaddress' | translate }}</h2> <h2>{{ 'core.login.siteaddress' | translate }}</h2>
</ion-label> </ion-label>
<ion-input name="url" type="url" placeholder="{{ 'core.login.siteaddressplaceholder' | translate }}" <ion-input name="url" type="url" placeholder="{{ 'core.login.siteaddressplaceholder' | translate }}"
formControlName="siteUrl" [core-auto-focus]="showKeyboard"> formControlName="siteUrl" [core-auto-focus]="showKeyboard && !showScanQR">
</ion-input> </ion-input>
</ion-item> </ion-item>
</ng-container> </ng-container>
@ -36,7 +36,7 @@
<h2>{{ 'core.login.siteaddress' | translate }}</h2> <h2>{{ 'core.login.siteaddress' | translate }}</h2>
</ion-label> </ion-label>
<ion-input name="url" placeholder="{{ 'core.login.siteaddressplaceholder' | translate }}" formControlName="siteUrl" <ion-input name="url" placeholder="{{ 'core.login.siteaddressplaceholder' | translate }}" formControlName="siteUrl"
[core-auto-focus]="showKeyboard" (ionChange)="searchSite($event, siteForm.value.siteUrl)"> [core-auto-focus]="showKeyboard && !showScanQR" (ionChange)="searchSite($event, siteForm.value.siteUrl)">
</ion-input> </ion-input>
</ion-item> </ion-item>

View File

@ -3,7 +3,7 @@
<ion-item> <ion-item>
<ion-label></ion-label> <ion-label></ion-label>
<ion-input type="search" name="search" [(ngModel)]="searchText" [placeholder]="placeholder" <ion-input type="search" name="search" [(ngModel)]="searchText" [placeholder]="placeholder"
[autocorrect]="autocorrect" [spellcheck]="spellcheck" [core-auto-focus]="autoFocus || 'nofocus'" [autocorrect]="autocorrect" [spellcheck]="spellcheck" [core-auto-focus]="autoFocus"
[disabled]="disabled" role="searchbox" (ionFocus)="focus($event)"> [disabled]="disabled" role="searchbox" (ionFocus)="focus($event)">
</ion-input> </ion-input>
<ion-button slot="end" fill="clear" type="submit" size="small" [attr.aria-label]="searchLabel" <ion-button slot="end" fill="clear" type="submit" size="small" [attr.aria-label]="searchLabel"

View File

@ -391,12 +391,11 @@ export class CoreDomUtilsProvider {
* Focus an element and open keyboard. * Focus an element and open keyboard.
* *
* @param el HTML element to focus. * @param el HTML element to focus.
* @param showKeyboard Show keyboard when focusing the element.
*/ */
focusElement(el: HTMLElement, showKeyboard = true): void { focusElement(el: HTMLElement): void {
if (el?.focus) { if (el?.focus) {
el.focus(); el.focus();
if (showKeyboard && CoreApp.isAndroid() && this.supportsInputKeyboard(el)) { if (CoreApp.isAndroid() && this.supportsInputKeyboard(el)) {
// On some Android versions the keyboard doesn't open automatically. // On some Android versions the keyboard doesn't open automatically.
CoreApp.openKeyboard(); CoreApp.openKeyboard();
} }