Make all emoji inputs screen-reader-friendly

This commit is contained in:
tusooa 2023-01-21 01:28:43 -05:00
parent 6235af4592
commit 72cb9e8bdb
No known key found for this signature in database
GPG Key ID: 7B467EDE43A08224
6 changed files with 58 additions and 30 deletions

View File

@ -287,6 +287,7 @@ const EmojiInput = {
...rest, ...rest,
img: imageUrl || '' img: imageUrl || ''
})) }))
this.highlighted = -1
this.$refs.screenReaderNotice.announce( this.$refs.screenReaderNotice.announce(
this.$tc('tool_tip.autocomplete_available', this.$tc('tool_tip.autocomplete_available',
this.suggestions.length, this.suggestions.length,

View File

@ -8,6 +8,7 @@ import Gallery from 'src/components/gallery/gallery.vue'
import StatusContent from '../status_content/status_content.vue' import StatusContent from '../status_content/status_content.vue'
import fileTypeService from '../../services/file_type/file_type.service.js' import fileTypeService from '../../services/file_type/file_type.service.js'
import { findOffset } from '../../services/offset_finder/offset_finder.service.js' import { findOffset } from '../../services/offset_finder/offset_finder.service.js'
import { propsToNative } from '../../services/attributes_helper/attributes_helper.service.js'
import { reject, map, uniqBy, debounce } from 'lodash' import { reject, map, uniqBy, debounce } from 'lodash'
import suggestor from '../emoji_input/suggestor.js' import suggestor from '../emoji_input/suggestor.js'
import { mapGetters, mapState } from 'vuex' import { mapGetters, mapState } from 'vuex'
@ -629,6 +630,9 @@ const PostStatusForm = {
}, },
openProfileTab () { openProfileTab () {
this.$store.dispatch('openSettingsModalTab', 'profile') this.$store.dispatch('openSettingsModalTab', 'profile')
},
propsToNative (props) {
return propsToNative(props)
} }
} }
} }

View File

@ -124,14 +124,17 @@
:suggest="emojiSuggestor" :suggest="emojiSuggestor"
class="form-control" class="form-control"
> >
<template #default="inputProps">
<input <input
v-model="newStatus.spoilerText" v-model="newStatus.spoilerText"
type="text" type="text"
:placeholder="$t('post_status.content_warning')" :placeholder="$t('post_status.content_warning')"
:disabled="posting && !optimisticPosting" :disabled="posting && !optimisticPosting"
v-bind="propsToNative(inputProps)"
size="1" size="1"
class="form-post-subject" class="form-post-subject"
> >
</template>
</EmojiInput> </EmojiInput>
<EmojiInput <EmojiInput
ref="emoji-input" ref="emoji-input"
@ -158,11 +161,7 @@
:disabled="posting && !optimisticPosting" :disabled="posting && !optimisticPosting"
class="form-post-body" class="form-post-body"
:class="{ 'scrollable-form': !!maxHeight }" :class="{ 'scrollable-form': !!maxHeight }"
v-bind="inputProps" v-bind="propsToNative(inputProps)"
:aria-owns="inputProps.ariaOwns"
:aria-autocomplete="inputProps.ariaAutocomplete"
:aria-activedescendant="inputProps.ariaActiveDescendant"
:aria-expanded="inputProps.ariaExpanded"
@keydown.exact.enter="submitOnEnter && postStatus($event, newStatus)" @keydown.exact.enter="submitOnEnter && postStatus($event, newStatus)"
@keydown.meta.enter="postStatus($event, newStatus)" @keydown.meta.enter="postStatus($event, newStatus)"
@keydown.ctrl.enter="!submitOnEnter && postStatus($event, newStatus)" @keydown.ctrl.enter="!submitOnEnter && postStatus($event, newStatus)"

View File

@ -12,6 +12,7 @@ import InterfaceLanguageSwitcher from 'src/components/interface_language_switche
import BooleanSetting from '../helpers/boolean_setting.vue' import BooleanSetting from '../helpers/boolean_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js' import SharedComputedObject from '../helpers/shared_computed_object.js'
import localeService from 'src/services/locale/locale.service.js' import localeService from 'src/services/locale/locale.service.js'
import { propsToNative } from 'src/services/attributes_helper/attributes_helper.service.js'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { import {
@ -257,6 +258,9 @@ const ProfileTab = {
messageArgs: [error.message], messageArgs: [error.message],
level: 'error' level: 'error'
}) })
},
propsToNative (props) {
return propsToNative(props)
} }
} }
} }

View File

@ -8,11 +8,14 @@
enable-emoji-picker enable-emoji-picker
:suggest="emojiSuggestor" :suggest="emojiSuggestor"
> >
<template #default="inputProps">
<input <input
id="username" id="username"
v-model="newName" v-model="newName"
class="name-changer" class="name-changer"
v-bind="propsToNative(inputProps)"
> >
</template>
</EmojiInput> </EmojiInput>
<p>{{ $t('settings.bio') }}</p> <p>{{ $t('settings.bio') }}</p>
<EmojiInput <EmojiInput
@ -20,10 +23,13 @@
enable-emoji-picker enable-emoji-picker
:suggest="emojiUserSuggestor" :suggest="emojiUserSuggestor"
> >
<template #default="inputProps">
<textarea <textarea
v-model="newBio" v-model="newBio"
class="bio resize-height" class="bio resize-height"
v-bind="propsToNative(inputProps)"
/> />
</template>
</EmojiInput> </EmojiInput>
<p v-if="role === 'admin' || role === 'moderator'"> <p v-if="role === 'admin' || role === 'moderator'">
<Checkbox v-model="showRole"> <Checkbox v-model="showRole">
@ -48,10 +54,13 @@
hide-emoji-button hide-emoji-button
:suggest="userSuggestor" :suggest="userSuggestor"
> >
<template #default="inputProps">
<input <input
v-model="newFields[i].name" v-model="newFields[i].name"
:placeholder="$t('settings.profile_fields.name')" :placeholder="$t('settings.profile_fields.name')"
v-bind="propsToNative(inputProps)"
> >
</template>
</EmojiInput> </EmojiInput>
<EmojiInput <EmojiInput
v-model="newFields[i].value" v-model="newFields[i].value"
@ -59,10 +68,13 @@
hide-emoji-button hide-emoji-button
:suggest="userSuggestor" :suggest="userSuggestor"
> >
<template #default="inputProps">
<input <input
v-model="newFields[i].value" v-model="newFields[i].value"
:placeholder="$t('settings.profile_fields.value')" :placeholder="$t('settings.profile_fields.value')"
v-bind="propsToNative(inputProps)"
> >
</template>
</EmojiInput> </EmojiInput>
<button <button
class="delete-field button-unstyled -hover-highlight" class="delete-field button-unstyled -hover-highlight"

View File

@ -0,0 +1,8 @@
import { kebabCase } from 'lodash'
const propsToNative = props => Object.keys(props).reduce((acc, cur) => {
acc[kebabCase(cur)] = props[cur]
return acc
}, {})
export { propsToNative }