mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
Misc changes 2
This commit is contained in:
@ -515,10 +515,10 @@ export class DateTime extends BaseInput<DateTimeData> implements AfterContentIni
|
|||||||
this.validate();
|
this.validate();
|
||||||
|
|
||||||
// Present picker
|
// Present picker
|
||||||
this._setFocus();
|
this._fireFocus();
|
||||||
picker.present(pickerOptions);
|
picker.present(pickerOptions);
|
||||||
picker.onDidDismiss(() => {
|
picker.onDidDismiss(() => {
|
||||||
this._setBlur();
|
this._fireBlur();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ export class Range extends BaseInput<any> implements AfterViewInit, ControlValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
// trigger ionFocus event
|
// trigger ionFocus event
|
||||||
this._setFocus();
|
this._fireFocus();
|
||||||
|
|
||||||
// prevent default so scrolling does not happen
|
// prevent default so scrolling does not happen
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
@ -361,7 +361,7 @@ export class Range extends BaseInput<any> implements AfterViewInit, ControlValue
|
|||||||
this._haptic.gestureSelectionEnd();
|
this._haptic.gestureSelectionEnd();
|
||||||
|
|
||||||
// trigger ionBlur event
|
// trigger ionBlur event
|
||||||
this._setBlur();
|
this._fireBlur();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
|
@ -5,8 +5,6 @@ import { Config } from '../../config/config';
|
|||||||
import { BaseInput } from '../../util/base-input';
|
import { BaseInput } from '../../util/base-input';
|
||||||
import { isPresent, isTrueProperty } from '../../util/util';
|
import { isPresent, isTrueProperty } from '../../util/util';
|
||||||
import { Platform } from '../../platform/platform';
|
import { Platform } from '../../platform/platform';
|
||||||
import { TimeoutDebouncer } from '../../util/debouncer';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Searchbar
|
* @name Searchbar
|
||||||
@ -300,7 +298,7 @@ export class Searchbar extends BaseInput<string> {
|
|||||||
* Sets the Searchbar to focused and active on input focus.
|
* Sets the Searchbar to focused and active on input focus.
|
||||||
*/
|
*/
|
||||||
inputFocused(ev: UIEvent) {
|
inputFocused(ev: UIEvent) {
|
||||||
this._setFocus();
|
this._fireFocus();
|
||||||
this._isActive = true;
|
this._isActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +315,7 @@ export class Searchbar extends BaseInput<string> {
|
|||||||
this._shouldBlur = true;
|
this._shouldBlur = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._setBlur();
|
this._fireBlur();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -352,8 +350,8 @@ export class Searchbar extends BaseInput<string> {
|
|||||||
this._isActive = false;
|
this._isActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_setFocus() {
|
_fireFocus() {
|
||||||
this._renderer.invokeElementMethod(this._searchbarInput.nativeElement, 'focus');
|
this._renderer.invokeElementMethod(this._searchbarInput.nativeElement, 'focus');
|
||||||
super._setFocus();
|
super._fireFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,9 +326,9 @@ export class Select extends BaseInput<string[]> implements AfterViewInit, OnDest
|
|||||||
}
|
}
|
||||||
|
|
||||||
overlay.present(selectOptions);
|
overlay.present(selectOptions);
|
||||||
this._setFocus();
|
this._fireFocus();
|
||||||
overlay.onDidDismiss(() => {
|
overlay.onDidDismiss(() => {
|
||||||
this._setBlur();
|
this._fireBlur();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ export class Toggle extends BaseInput<boolean> implements IonicTapInput, AfterVi
|
|||||||
console.debug('toggle, _onDragStart', startX);
|
console.debug('toggle, _onDragStart', startX);
|
||||||
|
|
||||||
this._startX = startX;
|
this._startX = startX;
|
||||||
this._setFocus();
|
this._fireFocus();
|
||||||
this._activated = true;
|
this._activated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ export class Toggle extends BaseInput<boolean> implements IonicTapInput, AfterVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._activated = false;
|
this._activated = false;
|
||||||
this._setBlur();
|
this._fireBlur();
|
||||||
this._startX = null;
|
this._startX = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { NgZone, ElementRef, EventEmitter, Input, Output, Renderer } from '@angular/core';
|
import { ElementRef, EventEmitter, Input, Output, Renderer } from '@angular/core';
|
||||||
import { ControlValueAccessor } from '@angular/forms';
|
import { ControlValueAccessor } from '@angular/forms';
|
||||||
import { NgControl } from '@angular/forms';
|
import { NgControl } from '@angular/forms';
|
||||||
|
|
||||||
@ -174,11 +174,11 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
|||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
_inputFireFocus() {
|
_fireFocus() {
|
||||||
if (this._isFocus) {
|
if (this._isFocus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert(NgZone.isInAngularZone(), 'callback should be zoned');
|
// assert(NgZone.isInAngularZone(), 'callback should be zoned');
|
||||||
|
|
||||||
this._isFocus = true;
|
this._isFocus = true;
|
||||||
this.ionFocus.emit(this);
|
this.ionFocus.emit(this);
|
||||||
@ -188,11 +188,11 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
|||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
_inputFireBlur() {
|
_fireBlur() {
|
||||||
if (!this._isFocus) {
|
if (!this._isFocus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert(NgZone.isInAngularZone(), 'callback should be zoned');
|
// assert(NgZone.isInAngularZone(), 'callback should be zoned');
|
||||||
|
|
||||||
this._isFocus = false;
|
this._isFocus = false;
|
||||||
this.ionBlur.emit(this);
|
this.ionBlur.emit(this);
|
||||||
|
@ -81,15 +81,15 @@ function testState<T>(input: BaseInput<T>, config: TestConfig, isInit: boolean)
|
|||||||
assertEqual(ev, input, 'ionFocus argument is wrong');
|
assertEqual(ev, input, 'ionFocus argument is wrong');
|
||||||
focusCount++;
|
focusCount++;
|
||||||
});
|
});
|
||||||
input._setFocus();
|
input._fireFocus();
|
||||||
assertEqual(input._isFocus, true, 'should be focus');
|
assertEqual(input._isFocus, true, 'should be focus');
|
||||||
assertEqual(input.isFocus(), true, 'should be focus');
|
assertEqual(input.isFocus(), true, 'should be focus');
|
||||||
input._setFocus();
|
input._fireFocus();
|
||||||
|
|
||||||
input._setBlur();
|
input._fireBlur();
|
||||||
assertEqual(input._isFocus, false, 'should be not focus');
|
assertEqual(input._isFocus, false, 'should be not focus');
|
||||||
assertEqual(input.isFocus(), false, 'should be not focus');
|
assertEqual(input.isFocus(), false, 'should be not focus');
|
||||||
input._setBlur(); // it should not crash
|
input._fireBlur(); // it should not crash
|
||||||
|
|
||||||
assertEqual(focusCount, 1, 'ionFocus was not called correctly');
|
assertEqual(focusCount, 1, 'ionFocus was not called correctly');
|
||||||
assertEqual(blurCount, 1, 'ionBlur was not called correctly');
|
assertEqual(blurCount, 1, 'ionBlur was not called correctly');
|
||||||
|
Reference in New Issue
Block a user