Skip to content

Commit a013497

Browse files
authored
feat(QField): improve a11y - add alert role to error messages, add aria-invalid quasarframework#8884 (quasarframework#9988)
1 parent dd8fa3d commit a013497

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

ui/dev/src/pages/form/form.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
export default {
186186
components: {
187187
customInput: {
188+
inheritAttrs: false,
188189
props: [ 'value' ],
189190
render (h) {
190191
return h('q-field', {
@@ -201,6 +202,7 @@ export default {
201202
},
202203
203204
myComp: {
205+
inheritAttrs: false,
204206
render (h) {
205207
return h('div', {
206208
staticClass: 'q-validation-component'

ui/src/components/field/QField.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export default Vue.extend({
394394

395395
if (this.hasError === true) {
396396
if (this.computedErrorMessage !== void 0) {
397-
msg = [ h('div', [ this.computedErrorMessage ]) ]
397+
msg = [ h('div', { attrs: { role: 'alert' } }, [ this.computedErrorMessage ]) ]
398398
key = this.computedErrorMessage
399399
}
400400
else {

ui/src/mixins/validate.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export default {
6767
this.validate()
6868
}
6969
}
70+
},
71+
72+
hasError (invalid) {
73+
const targetEl = document.getElementById(this.targetUid)
74+
targetEl !== null && targetEl.setAttribute('aria-invalid', invalid === true)
7075
}
7176
},
7277

0 commit comments

Comments
 (0)