mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-09 21:57:47 +02:00
Enhance accessibility with correct keyboard navigation and focus style
This commit is contained in:
@ -1,11 +1,29 @@
|
||||
<template>
|
||||
<div class="field" :class="{ 'pt-3' : hasOffset }">
|
||||
<label class="label" v-html="label"></label>
|
||||
<div class="field" :class="{ 'pt-3' : hasOffset }" role="radiogroup" :aria-labelledby="inputId('label', fieldName)">
|
||||
<label :id="inputId('label', fieldName)" class="label" v-html="label"></label>
|
||||
<div class="is-toggle buttons">
|
||||
<label class="button is-dark" :disabled="isDisabled" v-for="(choice, index) in choices" :key="index" :class="{ 'is-link' : form[fieldName] === choice.value }">
|
||||
<input type="radio" class="is-hidden" :checked="form[fieldName] === choice.value" :value="choice.value" v-model="form[fieldName]" v-on:change="$emit(fieldName, form[fieldName])" :disabled="isDisabled" />
|
||||
<button
|
||||
role="radio"
|
||||
type="button"
|
||||
class="button is-dark"
|
||||
:aria-checked="form[fieldName] === choice.value"
|
||||
:disabled="isDisabled"
|
||||
v-for="(choice, index) in choices"
|
||||
:key="index"
|
||||
:class="{ 'is-link' : form[fieldName] === choice.value }"
|
||||
v-on:click.stop="setRadio(choice.value)"
|
||||
>
|
||||
<input
|
||||
:id="inputId(inputType, choice.value)"
|
||||
:type="inputType"
|
||||
class="is-hidden"
|
||||
:checked="form[fieldName] === choice.value"
|
||||
:value="choice.value"
|
||||
v-model="form[fieldName]"
|
||||
:disabled="isDisabled"
|
||||
/>
|
||||
<font-awesome-icon :icon="['fas', choice.icon]" v-if="choice.icon" class="mr-3" /> {{ choice.text }}
|
||||
</label>
|
||||
</button>
|
||||
</div>
|
||||
<field-error :form="form" :field="fieldName" />
|
||||
<p class="help" v-html="help" v-if="help"></p>
|
||||
@ -18,7 +36,7 @@
|
||||
|
||||
data() {
|
||||
return {
|
||||
|
||||
inputType: 'radio'
|
||||
}
|
||||
},
|
||||
|
||||
@ -58,6 +76,13 @@
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
setRadio(event) {
|
||||
this.form[this.fieldName] = event
|
||||
this.$emit(this.fieldName, this.form[this.fieldName])
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Reference in New Issue
Block a user