Skip to content

Commit ff6d076

Browse files
authored
Merge pull request #3238 from nextcloud/fix/2858-a11y-issues
fix(a11y): announce form submission success to screen readers
2 parents 3e19f7f + 8c296e1 commit ff6d076

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/views/Submit.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
</p>
5050
</header>
5151

52+
<!-- Screen-reader-only live region for submission success announcement -->
53+
<div class="hidden-visually" aria-live="polite">
54+
{{ successAnnouncement }}
55+
</div>
56+
5257
<NcEmptyContent
5358
v-if="loading"
5459
class="forms-emptycontent"
@@ -326,6 +331,7 @@ export default {
326331
answers: {},
327332
loading: false,
328333
success: false,
334+
successAnnouncement: '',
329335
/** Submit state of the form, true if changes are currently submitted */
330336
submitForm: false,
331337
showConfirmEmptyModal: false,
@@ -498,6 +504,22 @@ export default {
498504
},
499505
500506
watch: {
507+
success(newVal) {
508+
if (newVal) {
509+
// Delay populating the live region to avoid the announcement being
510+
// swallowed by the simultaneous large DOM change (form replaced by
511+
// success view). Screen readers need a moment to process the new DOM
512+
// before a polite live region update registers.
513+
setTimeout(() => {
514+
this.successAnnouncement =
515+
this.form.submissionMessage
516+
|| t('forms', 'Thank you for completing the form!')
517+
}, 100)
518+
} else {
519+
this.successAnnouncement = ''
520+
}
521+
},
522+
501523
hash() {
502524
// If public view, abort. Should normally not occur.
503525
if (this.publicView) {

0 commit comments

Comments
 (0)