Skip to content

Commit

Permalink
add @type argument to FlInput
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Pafundi committed Jun 22, 2022
1 parent b7e4ac9 commit e351e9c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion addon/components/fl-input/fl-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
</label>
{{/if}}
{{else}}
<Input @value={{@value}} class="{{this.inputBaseClass}}" id={{this.id}} name={{this.name}} ...attributes />
<Input
@value={{@value}}
@type={{this.type}}
class="{{this.inputBaseClass}}"
id={{this.id}}
name={{this.name}}
...attributes
/>
{{#if this.placeholder}}
<label class="control-label fl-placeholder-label" for={{this.id}}>
{{this.placeholder}}
Expand Down
5 changes: 5 additions & 0 deletions addon/components/fl-input/fl-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface FlInputArgs {
inset?: boolean;
id?: string;
name?: string;
type?: string;
errors?: string[];
}

Expand Down Expand Up @@ -65,6 +66,10 @@ export default class FlInput<T extends FlInputArgs> extends Component<T> {
return this.firstError ?? this.args.placeholder;
}

get type(): string {
return this.args.type ?? 'text';
}

/**
* Updates the component's focused state when it recieves focus
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/components/fl-input-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ module('Integration | Component | fl-input', function (hooks) {
await a11yAudit();
assert.strictEqual(this.element.textContent?.trim(), 'test');
});

test('Type attribute is set on the <input> when using <FlInput />', async function (assert) {
await render(hbs`<FlInput @placeholder="password" @type="password"/>`);
await a11yAudit();
const inputElement = this.element.querySelector('input') as HTMLInputElement;
assert.equal(inputElement.type, 'password');
});
});

0 comments on commit e351e9c

Please sign in to comment.