FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add support for :focus pseudo class in TextField/TextView (#7396) · NativeScript/NativeScript@0bfddab · GitHub

Commit 0bfddab

Browse files
authored andcommitted
Add support for :focus pseudo class in TextField/TextView (#7396)
1 parent 2d68a40 commit 0bfddab

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎tns-core-modules/ui/editable-text-base/editable-text-base-common.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EditableTextBase as EditableTextBaseDefinition, KeyboardType, ReturnKeyType, UpdateTextTrigger, AutocapitalizationType } from ".";
2-
import { TextBase, Property, CssProperty, Style, Color, booleanConverter, makeValidator, makeParser } from "../text-base";
2+
import { TextBase, Property, CssProperty, Style, Color, booleanConverter, makeValidator, makeParser, PseudoClassHandler } from "../text-base";
33

44
export * from "../text-base";
55

@@ -18,6 +18,17 @@ export abstract class EditableTextBase extends TextBase implements EditableTextB
1818

1919
public abstract dismissSoftInput();
2020
public abstract _setInputType(inputType: number): void;
21+
22+
private _focusHandler = () => this._goToVisualState("focus");
23+
private _blurHandler = () => this._goToVisualState("blur");
24+
25+
@PseudoClassHandler("focus", "blur")
26+
_updateHandler(subscribe) {
27+
const method = subscribe ? "on" : "off";
28+
29+
this[method]("focus", this._focusHandler);
30+
this[method]("blur", this._blurHandler);
31+
};
2132
}
2233

2334
// TODO: Why not name it - hintColor property??

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL