-
Notifications
You must be signed in to change notification settings - Fork 419
Filter error keywords before touch #2540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import { | |
| defaultJsonFormsI18nState, | ||
| getArrayTranslations, | ||
| getCombinatorTranslations, | ||
| getControlPath, | ||
| getFirstPrimitiveProp, | ||
| isDescriptionHidden, | ||
| type ControlElement, | ||
|
|
@@ -176,10 +177,38 @@ export const useVuetifyControl = < | |
| isFocused.value = false; | ||
| }; | ||
|
|
||
| const jsonforms = useJsonForms(); | ||
| const filteredErrors = computed(() => { | ||
| return touched.value || !appliedOptions.value.enableFilterErrorsBeforeTouch | ||
| ? input.control.value.errors | ||
| : ''; | ||
| // Always show errors if touched, no errors exist, or filtering is not enabled | ||
| if ( | ||
| touched.value || | ||
| !input.control.value.errors || | ||
| !appliedOptions.value.enableFilterErrorsBeforeTouch | ||
| ) { | ||
| return input.control.value.errors; | ||
| } | ||
|
Comment on lines
+183
to
+189
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these changes also be done for array children errors? Currently they continue to show their errors |
||
|
|
||
| const filterKeywords = appliedOptions.value.filterErrorKeywordsBeforeTouch; | ||
|
|
||
| // Filtering is enabled - check if specific keywords are configured | ||
| if (Array.isArray(filterKeywords) && filterKeywords.length > 0) { | ||
| // Granular filtering: only hide specific error keywords | ||
|
Comment on lines
+193
to
+195
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I interpreted the comments to filter specific keywords, also the option is named So if "Error A" is filtered but the control has both "Error A" and "Error B", then the control will show both "Error A" and "Error B". We either need to adapt the functionality if this was not intended or rename the option and/or adapt the comments. |
||
| const errorsAtControl = | ||
| jsonforms.core?.errors?.filter( | ||
| (error) => input.control.value.path === getControlPath(error), | ||
| ) ?? []; | ||
|
|
||
| const allErrorsFiltered = | ||
| errorsAtControl.length > 0 && | ||
| errorsAtControl.every( | ||
| (error) => error.keyword && filterKeywords.includes(error.keyword), | ||
| ); | ||
|
|
||
| return allErrorsFiltered ? '' : input.control.value.errors; | ||
| } | ||
|
|
||
| // default, all errors are filtered | ||
| return ''; | ||
| }); | ||
|
|
||
| const persistentHint = (): boolean => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: We are already within JSON Forms state so you could just use
const jsonforms = inject<JsonFormsSubStates>('jsonforms')directly.