Skip to content

Commit

Permalink
fix(Input): correctly reflect disabled status to the native element
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincharity committed Oct 31, 2019
1 parent 5eb61ba commit fa091c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions terminus-ui/input/src/input.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
[attr.autocapitalize]="autocapitalize ? 'on' : 'off'"
[attr.autocomplete]="autocomplete"
[attr.autofocus]="isFocused ? '' : null"
[attr.disabled]="shouldBeDisabled ? '' : null"
[disabled]="shouldBeDisabled"
[attr.name]="name"
[attr.id]="id"
[readonly]="readOnly"
Expand All @@ -119,7 +119,7 @@
[attr.autocapitalize]="autocapitalize ? 'on' : 'off'"
[attr.autocomplete]="autocomplete"
[attr.autofocus]="isFocused ? '' : null"
[attr.disabled]="shouldBeDisabled ? '' : null"
[disabled]="shouldBeDisabled"
[attr.name]="name"
[attr.id]="id"
[readonly]="readOnly"
Expand Down Expand Up @@ -148,7 +148,7 @@
[attr.autocapitalize]="autocapitalize ? 'on' : 'off'"
[attr.autocomplete]="autocomplete"
[attr.autofocus]="isFocused ? '' : null"
[attr.disabled]="shouldBeDisabled ? '' : null"
[disabled]="shouldBeDisabled"
[attr.name]="name"
[attr.id]="id"
[attr.rows]="textareaRows"
Expand Down
11 changes: 6 additions & 5 deletions terminus-ui/input/src/input.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,18 @@ describe(`TsInputComponent`, function() {
});


test(`should set the disabled flag when appropriate`, () => {
test(`should set the disabled flag when appropriate`, fakeAsync(() => {
const fixture = createComponent(TestComponents.AttrDisabled);
fixture.detectChanges();
const el = getInputElement(fixture);
expect(el.getAttribute('disabled')).toEqual(null);
const inputElement = getInputElement(fixture);
expect(inputElement.disabled).toEqual(false);

fixture.componentInstance.disabled = true;
fixture.detectChanges();
tick();

expect(el.getAttribute('disabled')).toEqual('');
});
expect(inputElement.disabled).toEqual(true);
}));


test(`should set autofocus`, () => {
Expand Down

0 comments on commit fa091c7

Please sign in to comment.