Skip to content

Commit

Permalink
fix: fix bug where required fields were not being enforced (#8455)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiekeller authored Jun 16, 2021
1 parent 1ba2a1f commit e8f9e5a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/amplify-ui-components/src/components.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class AmplifyFormField {
value={this.value}
inputProps={this.inputProps}
disabled={this.disabled}
required={this.required}
/>
</slot>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@ describe('amplify-input spec:', () => {
it('should have `type` set to `text` by default', () => {
expect(input.type).toEqual('text');
});

it('should have `required` set to `false` by default', () => {
expect(input.required).toBe(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export class AmplifyInput {
@Prop() inputProps?: object;
/** Will disable the input if set to true */
@Prop() disabled?: boolean;
/** Whether the input is a required field */
@Prop() required?: boolean = false;
/** Whether the input has been autocompleted */
@State() autoCompleted = false;
private removeHubListener: () => void;
Expand Down Expand Up @@ -132,6 +134,7 @@ export class AmplifyInput {
class="input"
value={this.value}
disabled={this.disabled}
required={this.required}
{...this.inputProps}
/>
</Host>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ export class AmplifyPhoneField {
render() {
return (
<div>
<amplify-form-field
label={I18n.get(this.label)}
hint={this.hint}
required={this.required}
>
<amplify-form-field label={I18n.get(this.label)} hint={this.hint}>
<div class="phone-field" slot="input">
<amplify-country-dial-code
dialCode={this.dialCode}
Expand All @@ -51,6 +47,7 @@ export class AmplifyPhoneField {
value={this.value}
inputProps={this.inputProps}
disabled={this.disabled}
required={this.required}
/>
</div>
</amplify-form-field>
Expand Down

0 comments on commit e8f9e5a

Please sign in to comment.