Re-validate form inputs when model is changed from outside.
* This fixes the issue of the coordinates input still being displayed as invalid after pickig coordinates from the map.
This commit is contained in:
parent
903a1bcf8a
commit
9387df8dd3
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, getCurrentInstance, onMounted, ref } from "vue";
|
import { computed, getCurrentInstance, onMounted, ref, watch } from "vue";
|
||||||
import { type Constraint, forConstraint } from "@/shared/validation/validator";
|
import { type Constraint, forConstraint } from "@/shared/validation/validator";
|
||||||
import ExpandableHelpBox from "@/components/ExpandableHelpBox.vue";
|
import ExpandableHelpBox from "@/components/ExpandableHelpBox.vue";
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ const hasResetIcon = computed(
|
||||||
() => !!(props.modelValue && props.resetIconTitle)
|
() => !!(props.modelValue && props.resetIconTitle)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(props, () => {
|
||||||
|
onValueChange();
|
||||||
|
});
|
||||||
|
|
||||||
function registerValidationComponent() {
|
function registerValidationComponent() {
|
||||||
const instance = getCurrentInstance();
|
const instance = getCurrentInstance();
|
||||||
let parent = instance?.parent;
|
let parent = instance?.parent;
|
||||||
|
@ -64,6 +68,12 @@ function withInputElement(callback: (element: HTMLInputElement) => void): void {
|
||||||
callback(element);
|
callback(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onValueChange() {
|
||||||
|
if (validated.value) {
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onInput() {
|
function onInput() {
|
||||||
if (validated.value) {
|
if (validated.value) {
|
||||||
validate();
|
validate();
|
||||||
|
|
Loading…
Reference in a new issue