Merge branch 'tusooa/react-more-actions-fix' into 'develop'

Accessibility for react & extra buttons

See merge request pleroma/pleroma-fe!1869

(cherry picked from commit 18c0cf1845)

0026b35f Add alt text for react and extra-buttons popup
82063f34 Add aria-controls to extra-buttons trigger
5ff14837 Add changelog
This commit is contained in:
HJ 2023-11-12 23:06:14 +00:00
parent 3781f0e3bf
commit 84e2fa1a5e
10 changed files with 45 additions and 7 deletions

View File

@ -0,0 +1 @@
Add aria attributes to react and extra buttons

View File

@ -1,4 +1,5 @@
import Completion from '../../services/completion/completion.js' import Completion from '../../services/completion/completion.js'
import genRandomSeed from '../../services/random_seed/random_seed.service.js'
import EmojiPicker from '../emoji_picker/emoji_picker.vue' import EmojiPicker from '../emoji_picker/emoji_picker.vue'
import Popover from 'src/components/popover/popover.vue' import Popover from 'src/components/popover/popover.vue'
import ScreenReaderNotice from 'src/components/screen_reader_notice/screen_reader_notice.vue' import ScreenReaderNotice from 'src/components/screen_reader_notice/screen_reader_notice.vue'
@ -110,7 +111,7 @@ const EmojiInput = {
}, },
data () { data () {
return { return {
randomSeed: `${Math.random()}`.replace('.', '-'), randomSeed: genRandomSeed(),
input: undefined, input: undefined,
caretEl: undefined, caretEl: undefined,
highlighted: -1, highlighted: -1,

View File

@ -3,7 +3,7 @@
ref="popover" ref="popover"
trigger="click" trigger="click"
popover-class="emoji-picker popover-default" popover-class="emoji-picker popover-default"
:trigger-attrs="{ 'aria-hidden': true }" :trigger-attrs="{ 'aria-hidden': true, tabindex: -1 }"
@show="onPopoverShown" @show="onPopoverShown"
@close="onPopoverClosed" @close="onPopoverClosed"
> >

View File

@ -1,4 +1,5 @@
import Popover from '../popover/popover.vue' import Popover from '../popover/popover.vue'
import genRandomSeed from '../../services/random_seed/random_seed.service.js'
import ConfirmModal from '../confirm_modal/confirm_modal.vue' import ConfirmModal from '../confirm_modal/confirm_modal.vue'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { import {
@ -40,7 +41,8 @@ const ExtraButtons = {
data () { data () {
return { return {
expanded: false, expanded: false,
showingDeleteDialog: false showingDeleteDialog: false,
randomSeed: genRandomSeed()
} }
}, },
methods: { methods: {
@ -152,6 +154,15 @@ const ExtraButtons = {
editingAvailable () { return this.$store.state.instance.editingAvailable }, editingAvailable () { return this.$store.state.instance.editingAvailable },
shouldConfirmDelete () { shouldConfirmDelete () {
return this.$store.getters.mergedConfig.modalOnDelete return this.$store.getters.mergedConfig.modalOnDelete
},
triggerAttrs () {
return {
title: this.$t('status.more_actions'),
id: `popup-trigger-${this.randomSeed}`,
'aria-controls': `popup-menu-${this.randomSeed}`,
'aria-expanded': this.expanded,
'aria-haspopup': 'menu'
}
} }
} }
} }

View File

@ -2,6 +2,7 @@
<Popover <Popover
class="ExtraButtons" class="ExtraButtons"
trigger="click" trigger="click"
:trigger-attrs="triggerAttrs"
placement="top" placement="top"
:offset="{ y: 5 }" :offset="{ y: 5 }"
:bound-to="{ x: 'container' }" :bound-to="{ x: 'container' }"
@ -10,10 +11,15 @@
@close="onClose" @close="onClose"
> >
<template #content="{close}"> <template #content="{close}">
<div class="dropdown-menu"> <div
class="dropdown-menu"
role="menu"
:id="`popup-menu-${randomSeed}`"
>
<button <button
v-if="canMute && !status.thread_muted" v-if="canMute && !status.thread_muted"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="muteConversation" @click.prevent="muteConversation"
> >
<FAIcon <FAIcon
@ -24,6 +30,7 @@
<button <button
v-if="canMute && status.thread_muted" v-if="canMute && status.thread_muted"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="unmuteConversation" @click.prevent="unmuteConversation"
> >
<FAIcon <FAIcon
@ -34,6 +41,7 @@
<button <button
v-if="!status.pinned && canPin" v-if="!status.pinned && canPin"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="pinStatus" @click.prevent="pinStatus"
@click="close" @click="close"
> >
@ -45,6 +53,7 @@
<button <button
v-if="status.pinned && canPin" v-if="status.pinned && canPin"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="unpinStatus" @click.prevent="unpinStatus"
@click="close" @click="close"
> >
@ -57,6 +66,7 @@
<button <button
v-if="!status.bookmarked" v-if="!status.bookmarked"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="bookmarkStatus" @click.prevent="bookmarkStatus"
@click="close" @click="close"
> >
@ -68,6 +78,7 @@
<button <button
v-if="status.bookmarked" v-if="status.bookmarked"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="unbookmarkStatus" @click.prevent="unbookmarkStatus"
@click="close" @click="close"
> >
@ -80,6 +91,7 @@
<button <button
v-if="ownStatus && editingAvailable" v-if="ownStatus && editingAvailable"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="editStatus" @click.prevent="editStatus"
@click="close" @click="close"
> >
@ -91,6 +103,7 @@
<button <button
v-if="isEdited && editingAvailable" v-if="isEdited && editingAvailable"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="showStatusHistory" @click.prevent="showStatusHistory"
@click="close" @click="close"
> >
@ -102,6 +115,7 @@
<button <button
v-if="canDelete" v-if="canDelete"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="deleteStatus" @click.prevent="deleteStatus"
@click="close" @click="close"
> >
@ -112,6 +126,7 @@
</button> </button>
<button <button
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="copyLink" @click.prevent="copyLink"
@click="close" @click="close"
> >
@ -123,6 +138,7 @@
<a <a
v-if="!status.is_local" v-if="!status.is_local"
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
title="Source" title="Source"
:href="status.external_url" :href="status.external_url"
target="_blank" target="_blank"
@ -134,6 +150,7 @@
</a> </a>
<button <button
class="button-default dropdown-item dropdown-item-icon" class="button-default dropdown-item dropdown-item-icon"
role="menuitem"
@click.prevent="reportStatus" @click.prevent="reportStatus"
@click="close" @click="close"
> >

View File

@ -1,4 +1,5 @@
import Timeago from 'components/timeago/timeago.vue' import Timeago from 'components/timeago/timeago.vue'
import genRandomSeed from '../../services/random_seed/random_seed.service.js'
import RichContent from 'components/rich_content/rich_content.jsx' import RichContent from 'components/rich_content/rich_content.jsx'
import { forEach, map } from 'lodash' import { forEach, map } from 'lodash'
@ -13,7 +14,7 @@ export default {
return { return {
loading: false, loading: false,
choices: [], choices: [],
randomSeed: `${Math.random()}`.replace('.', '-') randomSeed: genRandomSeed()
} }
}, },
created () { created () {

View File

@ -1,4 +1,5 @@
import statusPoster from '../../services/status_poster/status_poster.service.js' import statusPoster from '../../services/status_poster/status_poster.service.js'
import genRandomSeed from '../../services/random_seed/random_seed.service.js'
import MediaUpload from '../media_upload/media_upload.vue' import MediaUpload from '../media_upload/media_upload.vue'
import ScopeSelector from '../scope_selector/scope_selector.vue' import ScopeSelector from '../scope_selector/scope_selector.vue'
import EmojiInput from '../emoji_input/emoji_input.vue' import EmojiInput from '../emoji_input/emoji_input.vue'
@ -162,7 +163,7 @@ const PostStatusForm = {
} }
return { return {
randomSeed: `${Math.random()}`.replace('.', '-'), randomSeed: genRandomSeed(),
dropFiles: [], dropFiles: [],
uploadingFiles: false, uploadingFiles: false,
error: null, error: null,

View File

@ -11,6 +11,8 @@
/> />
<span <span
class="button-unstyled popover-trigger" class="button-unstyled popover-trigger"
role="button"
:tabindex="0"
:title="$t('tool_tip.add_reaction')" :title="$t('tool_tip.add_reaction')"
@click.stop.prevent="show" @click.stop.prevent="show"
> >

View File

@ -1033,7 +1033,8 @@
"reaction_count_label": "{num} person reacted | {num} people reacted", "reaction_count_label": "{num} person reacted | {num} people reacted",
"hide_quote": "Hide the quoted status", "hide_quote": "Hide the quoted status",
"display_quote": "Display the quoted status", "display_quote": "Display the quoted status",
"invisible_quote": "Quoted status unavailable: {link}" "invisible_quote": "Quoted status unavailable: {link}",
"more_actions": "More actions on this status"
}, },
"user_card": { "user_card": {
"approve": "Approve", "approve": "Approve",

View File

@ -0,0 +1,3 @@
const genRandomSeed = () => `${Math.random()}`.replace('.', '-')
export default genRandomSeed