DigitalConsumer.ISS/src/mixins/base-form-mixin.js
Alex Humphries 99deeca4a8 INSR-7934: Update validation styles and focus behavior
- common-error-styles.scss renamed to common-validation-styles.scss
- Added 'has-success' to dropdown-question component
- Updated dropdown-question to only show error/success when not disabled
- Fixed issue with focusing first invalid input in base-form-mixin
2025-12-29 15:12:30 -05:00

31 lines
908 B
JavaScript

import showIssLoadingModal from '@/helpers/loading-modal-helper';
export default {
mounted() {
showIssLoadingModal(false);
},
methods: {
onSubmit() {
/**
* DO NOT REMOVE;
* Needed to prevent default form submit behavior.
* Cannot use .prevent modifier for vee-validate Form.
*/
},
onInvalidSubmit({ errors }) {
/**
* Identify the first error field and put focus on it
* get error names array
*/
const errorNames = errors ? Object.keys(errors) : [];
const firstErrorEl = errorNames[0];
if (firstErrorEl) {
const qsString = `[name="${firstErrorEl}"]`;
const el = document.querySelector(qsString);
if (el !== null) {
el.focus();
}
}
}
}
};