Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit f7600ed

Browse files
committed
fix(textfield): Fix getNativeInput adapter method and use foundation isDisabled.
1 parent 8382aa8 commit f7600ed

File tree

3 files changed

+17
-26
lines changed

3 files changed

+17
-26
lines changed

src/lib/textfield/textfield-adapter.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
deregisterInputKeydownHandler: (EventListener) => void;
1717
setHelptextAttr: (name: string, value: string) => void;
1818
removeHelptextAttr: (className: string) => void;
19-
getNativeInput: () => void;
19+
getNativeInput: () => HTMLInputElement;
2020
}

src/lib/textfield/textfield.component.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
[tabindex]="tabindex"
1111
[maxlength]="maxlength"
1212
[attr.aria-label]="placeholder"
13-
(focus)="handleFocus($event)"
14-
(blur)="handleBlur($event)"
15-
(input)="handleInput($event)"
16-
(keydown)="handleKeyDown($event)"
13+
(focus)="onFocus($event)"
14+
(blur)="onBlur($event)"
15+
(input)="onInput($event)"
16+
(keydown)="onKeyDown($event)"
1717
[(ngModel)]="value"
1818
[disabled]="disabled"
1919
[required]="required"></textarea>
@@ -31,8 +31,8 @@
3131
[disabled]="disabled"
3232
[required]="required"
3333
[attr.tabindex]="tabindex"
34-
(focus)="handleFocus($event)"
35-
(keydown)="handleKeyDown($event)"
36-
(blur)="handleBlur($event)"
37-
(input)="handleInput($event)" />
34+
(focus)="onFocus($event)"
35+
(keydown)="onKeyDown($event)"
36+
(blur)="onBlur($event)"
37+
(input)="onInput($event)" />
3838
<label #inputlabel [attr.for]="id" class="mdc-textfield__label" *ngIf="!placeholder">{{label}}</label>

src/lib/textfield/textfield.component.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,13 @@ type UnlistenerMap = WeakMap<EventListener, Function>;
3535
providers: [MD_TEXTFIELD_CONTROL_VALUE_ACCESSOR]
3636
})
3737
export class TextfieldComponent implements AfterViewInit, OnDestroy {
38-
private disabled_: boolean;
39-
4038
@Input() id: string;
39+
@Input() name: string;
4140
@Input() type: string = 'text';
4241
@Input() value: string;
4342
@Input()
44-
get disabled(): boolean {
45-
return this.disabled_;
46-
}
47-
set disabled(value: boolean) {
48-
this.disabled_ = value;
43+
get disabled() { return this._foundation.isDisabled(); }
44+
set disabled(value) {
4945
if (this.inputEl) {
5046
this._foundation.setDisabled(value);
5147
}
@@ -169,12 +165,7 @@ export class TextfieldComponent implements AfterViewInit, OnDestroy {
169165
}
170166
},
171167
getNativeInput: () => {
172-
return {
173-
checkValidity: () => this.inputEl.nativeElement.checkValidity(),
174-
value: this.value,
175-
disabled: (_) => this.disabled_ = _,
176-
badInput: this.inputEl.nativeElement.validity.badInput
177-
};
168+
return this.inputEl ? this.inputEl.nativeElement : null;
178169
}
179170
};
180171

@@ -194,22 +185,22 @@ export class TextfieldComponent implements AfterViewInit, OnDestroy {
194185
this._foundation.destroy();
195186
}
196187

197-
handleFocus(evt: FocusEvent) {
188+
onFocus(evt: FocusEvent) {
198189
this.focus.emit(evt);
199190
}
200191

201-
handleBlur(evt: FocusEvent) {
192+
onBlur(evt: FocusEvent) {
202193
this._controlValueAccessorChangeFn((<any>evt.target).value);
203194
this.blur.emit(evt);
204195
}
205196

206-
handleInput(evt: Event) {
197+
onInput(evt: Event) {
207198
evt.stopPropagation();
208199
this._controlValueAccessorChangeFn((<any>evt.target).value);
209200
this.input.emit(evt);
210201
}
211202

212-
handleKeyDown(evt: KeyboardEvent) {
203+
onKeyDown(evt: KeyboardEvent) {
213204
evt.stopPropagation();
214205
this.keydown.emit(evt);
215206
}

0 commit comments

Comments
 (0)