-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(menubar): menubar and table menus a11y #5218
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df1f3dc
fix: apply a11y attrs for session list trigger
ShGKme b53602a
fix(menubar): remove unneeded roles `menu`, `menuitem`
ShGKme a762115
fix(menubar): remove incorrect `aria-haspopup`
ShGKme 34d9710
fix(menubar): remove incorrect `aria-activedescendant`
ShGKme 21e76f3
fix(table): replace InlineActionsContainer by NcActionButtonGroup
ShGKme ada2fdd
fix(table): make text align buttons radio
ShGKme eb02f5d
fix(menubar): replace aria-pressed with text description in action list
ShGKme e5629fc
refactor: implement ActionSingle via template instead of render-function
ShGKme bfa83df
fix(menubar): set correct type for buttons instead of aria-selected
ShGKme af83b38
fix(menubar): separate NcActionButton from ActionSingle
ShGKme e851f88
fix(menubar): add separator between radio groups
ShGKme 9d31390
fix(menubar): name ActionFormattingHelp as NcActionButton to support β¦
ShGKme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
- @copyright Copyright (c) 2022 Vinicius Reis <[email protected]> | ||
- | ||
- @author Vinicius Reis <[email protected]> | ||
- @author Grigorii K. Shartsev <[email protected]> | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
|
@@ -23,37 +24,35 @@ | |
<template> | ||
<NcActions :title="tooltip" | ||
class="entry-list-action entry-action" | ||
role="menu" | ||
v-bind="state" | ||
:container="menuIDSelector" | ||
:aria-label="actionEntry.label" | ||
:aria-pressed="state.active" | ||
:aria-label="labelWithSelected" | ||
:type="state.active ? 'primary': 'tertiary'" | ||
:aria-activedescendant="currentChild ? `${$menuID}-child-${currentChild.key}` : null" | ||
:force-menu="true" | ||
:name="actionEntry.label" | ||
:data-text-action-entry="actionEntry.key" | ||
:data-text-action-active="activeKey" | ||
@update:open="onOpenChange"> | ||
<template #icon> | ||
<component :is="icon" :key="iconKey" /> | ||
</template> | ||
<ActionSingle v-for="child in children" | ||
:id="`${$menuID}-child-${child.key}`" | ||
:key="`child-${child.key}`" | ||
:active="currentChild?.key === child.key" | ||
is-item | ||
:action-entry="child" | ||
v-on="$listeners" | ||
@trigged="onTrigger" /> | ||
<template v-for="child in children"> | ||
<NcActionSeparator v-if="child.isSeparator" :key="`child-${child.key}`" /> | ||
<ActionListItem v-else | ||
:key="`child-${child.key}`" | ||
:active="currentChild?.key === child.key" | ||
is-item | ||
:action-entry="child" | ||
v-on="$listeners" | ||
@trigged="onTrigger" /> | ||
</template> | ||
<slot v-bind="{ visible }" name="lastAction" /> | ||
</NcActions> | ||
</template> | ||
|
||
<script> | ||
import { NcActions } from '@nextcloud/vue' | ||
import { NcActions, NcActionSeparator } from '@nextcloud/vue' | ||
import { BaseActionEntry } from './BaseActionEntry.js' | ||
import ActionSingle from './ActionSingle.vue' | ||
import ActionListItem from './ActionListItem.vue' | ||
import { getIsActive } from './utils.js' | ||
import { useOutlineStateMixin } from '../Editor/Wrapper.provider.js' | ||
import useStore from '../../mixins/store.js' | ||
|
@@ -63,7 +62,8 @@ export default { | |
name: 'ActionList', | ||
components: { | ||
NcActions, | ||
ActionSingle, | ||
NcActionSeparator, | ||
ActionListItem, | ||
}, | ||
extends: BaseActionEntry, | ||
mixins: [useStore, useOutlineStateMixin, useMenuIDMixin], | ||
|
@@ -110,6 +110,17 @@ export default { | |
: visible | ||
}) | ||
}, | ||
labelWithSelected() { | ||
if (this.currentChild) { | ||
// TRANSLATORS: examples - Headings, "Heading 1" is selected - Callouts, "Info" is selected | ||
return t('text', '{menuItemName}, "{selectedSubMenuItemName}" is selected', { | ||
menuItemName: this.actionEntry.label, | ||
selectedSubMenuItemName: this.currentChild.label, | ||
}) | ||
} | ||
|
||
return this.actionEntry.label | ||
}, | ||
}, | ||
methods: { | ||
onOpenChange(val) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2022 Vinicius Reis <[email protected]> | ||
- | ||
- @author Vinicius Reis <[email protected]> | ||
- @author Grigorii K. Shartsev <[email protected]> | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
- This program is free software: you can redistribute it and/or modify | ||
- it under the terms of the GNU Affero General Public License as | ||
- published by the Free Software Foundation, either version 3 of the | ||
- License, or (at your option) any later version. | ||
- | ||
- This program is distributed in the hope that it will be useful, | ||
- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
- GNU Affero General Public License for more details. | ||
- | ||
- You should have received a copy of the GNU Affero General Public License | ||
- along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
- | ||
--> | ||
|
||
<template> | ||
<NextcloudVueNcActionButton class="entry-single-action entry-action entry-action-item" | ||
:class="state.class" | ||
:disabled="state.disabled" | ||
:aria-keyshortcuts="keyshortcuts || undefined" | ||
:data-text-action-entry="actionEntry.key" | ||
:type="state.type" | ||
:model-value="state.type !== 'button' ? state.active : undefined" | ||
close-after-click | ||
v-on="$listeners" | ||
@click="runAction"> | ||
<template #icon> | ||
<component :is="icon" /> | ||
</template> | ||
{{ label }} | ||
</NextcloudVueNcActionButton> | ||
</template> | ||
|
||
<script> | ||
import { NcActionButton as NextcloudVueNcActionButton } from '@nextcloud/vue' | ||
import { BaseActionEntry } from './BaseActionEntry.js' | ||
|
||
export default { | ||
// This component is used as a direct child of NcActions. | ||
// Even if it actually renders NcActionButton, NcActions cannot see it due to rendering limitations in Vue. | ||
// Though it works in general, NcActions doesn't handle it correctly. See NcActions docs for details. | ||
// Hotfix - rename the component to NcActionButton because it represents and renders it. | ||
// eslint-disable-next-line vue/match-component-file-name | ||
name: 'NcActionButton', | ||
|
||
components: { | ||
NextcloudVueNcActionButton, | ||
}, | ||
|
||
extends: BaseActionEntry, | ||
|
||
mounted() { | ||
this.$editor.on('transaction', () => this.updateState()) | ||
}, | ||
|
||
methods: { | ||
runAction() { | ||
const { actionEntry } = this | ||
|
||
if (actionEntry.click) { | ||
actionEntry.click(this) | ||
} else { | ||
// Some actions run themselves. | ||
// others still need to have .run() called upon them. | ||
actionEntry.action(this.$editor.chain().focus())?.run() | ||
} | ||
|
||
this.$nextTick(() => { | ||
this.$emit('trigged', { ...actionEntry }) | ||
}) | ||
}, | ||
}, | ||
} | ||
</script> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The div here should be switched to span and the divs inside AvatarWrapper also need to be span to not have block-level elements inside the inline button
Otherwise good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I'll do it in another PR with fixing HTML validation issues.