Skip to content

Commit

Permalink
fix(cdk:forms): interactions trigger dosen't work (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Jan 2, 2024
1 parent e216b08 commit fc44cbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/cdk/forms/src/models/abstractControl.ts
Expand Up @@ -684,7 +684,7 @@ export abstract class AbstractControl<T = any> {
}

if (this.trigger === 'interactions') {
if ((!this.valid.value || !!oldValue) && !isChanging) {
if (((this.validated.value && !this.valid.value) || !!oldValue) && !isChanging) {
isChangeValidating = true
}

Expand All @@ -693,7 +693,9 @@ export abstract class AbstractControl<T = any> {
}
}

isChanging = true
if (this.dirty.value) {
isChanging = true
}
})
}
}
6 changes: 3 additions & 3 deletions packages/components/form/demo/InteractionsTrigger.vue
@@ -1,9 +1,9 @@
<template>
<IxForm class="demo-form" :control="formGroup">
<IxFormItem message="Please input your username!">
<IxFormItem>
<IxInput control="username" prefix="user"></IxInput>
</IxFormItem>
<IxFormItem message="Please input your password, its length is 6-18!">
<IxFormItem>
<IxInput control="password" prefix="lock" :type="passwordVisible ? 'text' : 'password'">
<template #suffix>
<IxIcon :name="passwordVisible ? 'eye-invisible' : 'eye'" @click="passwordVisible = !passwordVisible">
Expand Down Expand Up @@ -37,7 +37,7 @@ const { required, minLength, maxLength } = Validators
const formGroup = useFormGroup(
{
username: ['', required],
username: ['', maxLength(10)],
password: ['', [required, minLength(6), maxLength(18)]],
remember: [true],
},
Expand Down

0 comments on commit fc44cbf

Please sign in to comment.