Skip to content
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
9 changes: 5 additions & 4 deletions src/components/base-address/BaseAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,25 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
readonly isInactive: boolean

/** Called, possibly externally, to validate all registered form inputs. */
public validate (): any {
public async validate (): Promise<boolean> {
this.postalCodeRulesEnabled = true
await Vue.nextTick() // ensure postal code rules are functional before validating
return this.$refs.addressForm.validate()
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was that we didn't wait for the postal code component to process its rules (line 139) before we called to validate this form. So, the form didn't know if the postal code was invalid.

You'll be able to test this when I integrate it into Create UI :)


/** Called, possibly externally, to reset validation of all registered form inputs and clear their values. */
public reset (): any {
public reset (): void {
this.postalCodeRulesEnabled = false
return this.$refs.addressForm.reset()
}

/** Called, possibly externally, to reset validation of all registered form inputs without modifying their values. */
public resetValidation (): any {
public resetValidation (): void {
return this.$refs.addressForm.resetValidation()
}

/** When country changes, resets fields. */
onCountryChange () {
onCountryChange (): void {
this.addressLocal['addressRegion'] = ''
this.addressLocal['postalCode'] = ''
// clear any existing validation errors
Expand Down
4 changes: 2 additions & 2 deletions src/components/completing-party/CompletingParty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ export default class CompletingParty extends Vue {

/** When prop changes, validate the components. */
@Watch('validate')
private onValidate (): void {
private async onValidate (): Promise<void> {
this.$refs.completingPartyForm && this.$refs.completingPartyForm.validate()
this.$refs.mailingAddress && this.$refs.mailingAddress.validate()
this.$refs.mailingAddress && await this.$refs.mailingAddress.validate()
}

/** When prop changes, update local object. */
Expand Down
Loading