Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default name attr to input as placeholder #20

Merged
merged 5 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addon/components/fl-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@value={{@value}}
class="{{this.inputBaseClass}}"
id={{this.id}}
name={{this.name}}
...attributes
/>
{{#if @placeholder}}
Expand Down
6 changes: 6 additions & 0 deletions addon/components/fl-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { action } from '@ember/object';
import { guidFor } from '@ember/object/internals';
import ObjectProxy from '@ember/object/proxy';
import { scheduleOnce } from '@ember/runloop';
import { dasherize } from '@ember/string';
import { isEmpty } from '@ember/utils';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
Expand All @@ -14,6 +15,7 @@ export interface FlInputArgs {
inputBaseClass?: string;
inset?: boolean;
id?: string;
name?: string;
}

export default class FlInput<T extends FlInputArgs> extends Component<T> {
Expand Down Expand Up @@ -50,6 +52,10 @@ export default class FlInput<T extends FlInputArgs> extends Component<T> {
return this.args.id ?? `fl-input-${guidFor(this)}`;
}

get name() {
return this.args.name ?? dasherize(this.args.placeholder?.replace(/\W/g, '') ?? '');
}

/**
* Updates the component's focused state when it recieves focus
*/
Expand Down
1 change: 1 addition & 0 deletions addon/components/fl-select.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<select
class="{{this.inputBaseClass}}"
id={{this.id}}
name={{this.name}}
...attributes
{{on "change" this.onChange}}
>
Expand Down
1 change: 1 addition & 0 deletions addon/components/fl-textarea.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@value={{@value}}
class="{{this.inputBaseClass}}"
id={{this.id}}
name={{this.name}}
...attributes
/>
{{#if @placeholder}}
Expand Down