Skip to content

Commit

Permalink
Fixed #3021 - Improve ContextMenu implementation for Accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Oct 17, 2022
1 parent a179a2b commit 0542877
Show file tree
Hide file tree
Showing 5 changed files with 630 additions and 292 deletions.
6 changes: 6 additions & 0 deletions api-generator/components/contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const ContextMenuProps = [
default: 'true',
description: "Whether to apply 'router-link-active-exact' class if route exactly matches the item path."
},
{
name: 'tabindex',
type: 'number',
default: '0',
description: 'Index of the element in tabbing order.'
},
{
name: 'aria-label',
type: 'string',
Expand Down
43 changes: 41 additions & 2 deletions src/components/contextmenu/ContextMenu.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
import { MenuItem } from '../menuitem';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';

type ContextMenuAppendTo = 'body' | 'self' | string | undefined | HTMLElement;

Expand Down Expand Up @@ -34,6 +34,18 @@ export interface ContextMenuProps {
* Default value is true.
*/
exact?: boolean | undefined;
/**
* Index of the element in tabbing order.
*/
tabindex?: number | string | undefined;
/**
* Defines a string value that labels an interactive element.
*/
'aria-label'?: string | undefined;
/**
* Identifier of the underlying menu element.
*/
'aria-labelledby'?: string | undefined;
}

export interface ContextMenuSlots {
Expand All @@ -49,7 +61,34 @@ export interface ContextMenuSlots {
}) => VNode[];
}

export declare type ContextMenuEmits = {};
export declare type ContextMenuEmits = {
/**
* Callback to invoke when the component receives focus.
* @param {Event} event - Browser event.
*/
focus: (event: Event) => void;
/**
* Callback to invoke when the component loses focus.
* @param {Event} event - Browser event.
*/
blur: (event: Event) => void;
/**
* Callback to invoke before the popup is shown.
*/
'before-show': () => void;
/**
* Callback to invoke before the popup is hidden.
*/
'before-hide': () => void;
/**
* Callback to invoke when the popup is shown.
*/
show: () => void;
/**
* Callback to invoke when the popup is hidden.
*/
hide: () => void;
};

declare class ContextMenu extends ClassComponent<ContextMenuProps, ContextMenuSlots, ContextMenuEmits> {
/**
Expand Down
Loading

0 comments on commit 0542877

Please sign in to comment.