-
Notifications
You must be signed in to change notification settings - Fork 310
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
Form Editor v2.5 #599
Form Editor v2.5 #599
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 | ||||
---|---|---|---|---|---|---|
|
@@ -2,50 +2,65 @@ | |||||
<transition name="fade"> | ||||||
<div | ||||||
v-if="errorMessage" | ||||||
class="has-error text-sm text-red-500 -bottom-3" | ||||||
class="has-error text-xs text-red-500 mt-1" | ||||||
v-html="errorMessage" | ||||||
/> | ||||||
</transition> | ||||||
</template> | ||||||
|
||||||
<script> | ||||||
export default { | ||||||
name: "HasError", | ||||||
name: 'HasError', | ||||||
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. 💡 Codebase verification Inconsistent Quote Usage Detected for Component Names Multiple Vue component names use both single and double quotes. Please standardize quote usage across all component names to maintain consistency. 🔗 Analysis chainLGTM: Consistent quote usage The change from double quotes to single quotes for the component name is a good stylistic choice. To ensure consistency across the project, you may want to run the following command: This will help identify any inconsistencies in quote usage for component names across your Vue files. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check for inconsistent quote usage in Vue component names
rg -t vue "name: [\"'].*[\"']" --stats
Length of output: 207 Script: #!/bin/bash
# Check for inconsistent quote usage in Vue component names by targeting .vue files
rg -g '*.vue' 'name: [\"'].*[\"']' --stats
Length of output: 130 Script: #!/bin/bash
# Check for inconsistent quote usage in Vue component names by targeting .vue files
rg -g '*.vue' 'name: ["\'].*["\']' --stats
Length of output: 93 Script: #!/bin/bash
# Check for inconsistent quote usage in Vue component names by targeting .vue files
rg -g '*.vue' "name: [\"'].*[\"']" --stats
Length of output: 24795 |
||||||
props: { | ||||||
form: { | ||||||
type: Object, | ||||||
required: true, | ||||||
}, | ||||||
field: { | ||||||
fieldId: { | ||||||
type: String, | ||||||
required: true, | ||||||
}, | ||||||
fieldName: { | ||||||
type: String, | ||||||
required: false, | ||||||
}, | ||||||
}, | ||||||
computed: { | ||||||
errorMessage() { | ||||||
if (!this.form || !this.form.errors || !this.form.errors.any()) | ||||||
if (!this.form.errors || !this.form.errors.any()) | ||||||
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. Add null check for form.errors The current check could throw an error if -if (!this.form.errors || !this.form.errors.any())
+if (!this.form?.errors?.any()) 📝 Committable suggestion
Suggested change
|
||||||
return null | ||||||
const subErrorsKeys = Object.keys(this.form.errors.all()).filter( | ||||||
(key) => { | ||||||
return key.startsWith(this.field) && key !== this.field | ||||||
return key.startsWith(this.fieldId) && key !== this.fieldId | ||||||
}, | ||||||
) | ||||||
const baseError = | ||||||
this.form.errors.get(this.field) ?? | ||||||
(subErrorsKeys.length ? "This field has some errors:" : null) | ||||||
let baseError | ||||||
= this.form.errors.get(this.fieldId) | ||||||
?? (subErrorsKeys.length ? 'This field has some errors:' : null) | ||||||
// If no error and no sub errors, return | ||||||
if (!baseError) return null | ||||||
if (!baseError) | ||||||
return null | ||||||
|
||||||
return `<p class="text-red-500">${baseError}</p><ul class="list-disc list-inside">${subErrorsKeys.map( | ||||||
(key) => { | ||||||
return "<li>" + this.getSubError(key) + "</li>" | ||||||
}, | ||||||
)}</ul>` | ||||||
// Check if baseError starts with "The {field.name} field" and replace if necessary | ||||||
if (baseError.startsWith(`The ${this.fieldName} field`)) { | ||||||
baseError = baseError.replace(`The ${this.fieldName} field`, 'This field') | ||||||
} | ||||||
|
||||||
const coreError = `<p class='text-red-500'>${baseError}</p>` | ||||||
if (subErrorsKeys.length) { | ||||||
return coreError + `<ul class='list-disc list-inside'>${subErrorsKeys.map( | ||||||
(key) => { | ||||||
return `<li>${this.getSubError(key)}</li>` | ||||||
}, | ||||||
)}</ul>` | ||||||
} | ||||||
|
||||||
return coreError | ||||||
}, | ||||||
}, | ||||||
methods: { | ||||||
getSubError(subErrorKey) { | ||||||
return this.form.errors.get(subErrorKey).replace(subErrorKey, "item") | ||||||
return this.form.errors.get(subErrorKey).replace(subErrorKey, 'item') | ||||||
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. 🛠️ Refactor suggestion Consider making error key replacement configurable The hardcoded replacement of the key with 'item' might not be suitable for all contexts. Consider making this configurable through props. +props: {
+ subErrorReplacement: {
+ type: String,
+ default: 'item'
+ }
+},
methods: {
getSubError(subErrorKey) {
- return this.form.errors.get(subErrorKey).replace(subErrorKey, 'item')
+ return this.form.errors.get(subErrorKey).replace(subErrorKey, this.subErrorReplacement)
}
}
|
||||||
}, | ||||||
}, | ||||||
} | ||||||
|
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.
Accessibility concern with focus outline removal.
While the new focus and blur event listeners improve focus state tracking, removing the default focus outline (
focus:outline-none
) can negatively impact accessibility for keyboard users.Consider keeping the focus outline or replacing it with a custom focus indicator that meets accessibility standards. For example:
The addition of
@focus
and@blur
event listeners is a good improvement for managing focus state.Also applies to: 32-33