Merge branch 'tusooa/subject-hidden-popover-trigger' into 'develop'

Remove focusability on hidden popover in subject input

See merge request pleroma/pleroma-fe!2100
This commit is contained in:
HJ 2025-03-23 12:39:36 +00:00
commit b4458cb45b
5 changed files with 31 additions and 3 deletions

View file

@ -0,0 +1 @@
Remove focusability on hidden popover in subject input

View file

@ -55,7 +55,7 @@
ref="suggestorPopover" ref="suggestorPopover"
class="autocomplete-panel" class="autocomplete-panel"
placement="bottom" placement="bottom"
:trigger-attrs="{ 'aria-hidden': true }" :hide-trigger="true"
> >
<template #content> <template #content>
<div <div

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, tabindex: -1 }" :hide-trigger="true"
@show="onPopoverShown" @show="onPopoverShown"
@close="onPopoverClosed" @close="onPopoverClosed"
> >

View file

@ -1,3 +1,4 @@
/* global process */
const Popover = { const Popover = {
name: 'Popover', name: 'Popover',
props: { props: {
@ -48,6 +49,12 @@ const Popover = {
// Use styled button (to avoid nested buttons) // Use styled button (to avoid nested buttons)
normalButton: Boolean, normalButton: Boolean,
// Whether to hide the trigger totally
hideTrigger: {
type: Boolean,
default: false,
},
triggerAttrs: { triggerAttrs: {
type: Object, type: Object,
default: {} default: {}
@ -79,6 +86,26 @@ const Popover = {
childrenShown: new Set() childrenShown: new Set()
} }
}, },
computed: {
allTriggerAttrs () {
if (process.env.NODE_ENV === 'development') {
if ('aria-hidden' in this.triggerAttrs) {
throw new Error('Do not use aria-hidden in triggerAttrs. Instead set hideTrigger to true')
}
}
const attrs = {
...this.triggerAttrs,
}
if (this.hideTrigger) {
attrs['aria-hidden'] = true
attrs.tabindex = 1
}
return attrs
}
},
methods: { methods: {
setAnchorEl (el) { setAnchorEl (el) {
this.anchorEl = el this.anchorEl = el

View file

@ -9,7 +9,7 @@
class="popover-trigger-button" class="popover-trigger-button"
:class="normalButton ? 'button-default btn' : 'button-unstyled'" :class="normalButton ? 'button-default btn' : 'button-unstyled'"
type="button" type="button"
v-bind="triggerAttrs" v-bind="allTriggerAttrs"
@click="onClick" @click="onClick"
> >
<slot name="trigger" /> <slot name="trigger" />