From 57d33e1eb1e20c355341e3169d39ba3934358daf Mon Sep 17 00:00:00 2001 From: Richard Schreiber Date: Tue, 13 May 2025 13:36:11 +0200 Subject: [PATCH] [A11y] fix issues with labels and tabindex in widget (#5083) --- .../static/pretixpresale/js/widget/widget.js | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/src/pretix/static/pretixpresale/js/widget/widget.js b/src/pretix/static/pretixpresale/js/widget/widget.js index e35f28b29..e1edb677c 100644 --- a/src/pretix/static/pretixpresale/js/widget/widget.js +++ b/src/pretix/static/pretixpresale/js/widget/widget.js @@ -208,7 +208,7 @@ Vue.component('availbox', { template: ('
' + '' + '
' @@ -239,12 +239,12 @@ Vue.component('availbox', { + '>' + '' + '
' - + '' + + '' + '' - + '' + + '' + '
' + '
' + '
'), @@ -262,6 +262,15 @@ Vue.component('availbox', { this.$root.$emit('amounts_changed') }, computed: { + aria_labelledby: function () { + return this.$root.html_id + '-item-label-' + this.item.id; + }, + dec_label: function () { + return '- ' + (this.item.has_variations ? this.variation.value : this.item.name) + ': ' + strings.quantity_dec; + }, + inc_label: function () { + return '+ ' + (this.item.has_variations ? this.variation.value : this.item.name) + ': ' + strings.quantity_inc; + }, count_group_classes: function () { return { 'pretix-widget-item-count-group': !this.$root.use_native_spinners @@ -350,12 +359,12 @@ Vue.component('pricebox', { + ' ' + '' + '
' - + '{{ $root.currency }} ' + + '{{ $root.currency }} ' + '' + + ' step="any" v-bind:aria-labelledby="aria_labelledby" v-bind:aria-describedby="price_desc_id">' + '
' - + '' + + '' + '{{ taxline }}' + '' + ''), @@ -366,6 +375,7 @@ Vue.component('pricebox', { suggested_price: Object, original_price: String, mandatory_priced_addons: Boolean, + item_id: Number, }, methods: { stripHTML: function (s) { @@ -375,6 +385,18 @@ Vue.component('pricebox', { }, }, computed: { + aria_labelledby: function () { + return [ + this.$root.html_id + '-item-label-' + this.item_id, + this.price_box_id + ].join(" "); + }, + price_box_id: function () { + return this.$root.html_id + '-item-pricebox-' + this.item_id; + }, + price_desc_id: function () { + return this.$root.html_id + '-item-pricedesc-' + this.item_id; + }, display_price: function () { if (this.$root.display_net_prices) { return floatformat(parseFloat(this.price.net), 2); @@ -419,9 +441,6 @@ Vue.component('pricebox', { return '' + this.$root.currency + " " + this.display_price; } }, - free_price_label () { - return [strings.price, this.$root.currency].join(", ") - }, taxline: function () { if (this.$root.display_net_prices) { if (this.price.includes_mixed_tax_rate) { @@ -465,7 +484,7 @@ Vue.component('variation', { + '
' + '' + + ' :field_name="\'price_\' + item.id + \'_\' + variation.id" v-if="$root.showPrices" :item_id="item.id">' + '' + ' ' + '
' @@ -515,7 +534,7 @@ Vue.component('item', { + '' + '
' + '' + '{{ item.name }}' + '' @@ -1049,10 +1068,10 @@ Vue.component('pretix-widget-event-form', { + '
' + '
' - + '

'+ strings['redeem_voucher'] +'

' + + '

'+ strings['redeem_voucher'] +'

' + '
' + '
' - + '' + + '' + '
' + '' + '
' @@ -1071,6 +1090,9 @@ Vue.component('pretix-widget-event-form', { this.$root.$off('focus_voucher_field', this.focus_voucher_field) }, computed: { + aria_labelledby: function() { + return this.$root.html_id + '-voucher-headline'; + }, display_event_info: function () { return this.$root.display_event_info || (this.$root.display_event_info === null && (this.$root.events || this.$root.weeks || this.$root.days)); },