From 3bdaf4a2b9636cd53560b1120d9e7b7e4d96fd69 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Mon, 29 Aug 2022 02:15:56 +0100 Subject: [PATCH] Fixed #2895 - Improve Accordion implementation for Accessibility --- api-generator/components/accordion.js | 28 +++ api-generator/components/accordiontab.js | 42 ++++ src/components/accordion/Accordion.d.ts | 18 ++ src/components/accordion/Accordion.vue | 235 +++++++++++++----- src/components/accordiontab/AccordionTab.d.ts | 30 ++- src/components/accordiontab/AccordionTab.vue | 7 + src/views/accordion/AccordionDoc.vue | 177 +++++++++++-- 7 files changed, 446 insertions(+), 91 deletions(-) diff --git a/api-generator/components/accordion.js b/api-generator/components/accordion.js index 7ddb181c2..11b7fa0a1 100644 --- a/api-generator/components/accordion.js +++ b/api-generator/components/accordion.js @@ -28,6 +28,18 @@ const AccordionProps = [ type: "string", default: "pi-chevron-down", description: "Icon of a expanded tab." + }, + { + name: "tabindex", + type: "number", + default: "0", + description: "Index of the element in tabbing order." + }, + { + name: "selectOnFocus", + type: "boolean", + default: "false", + description: "When enabled, the focused tab is activated." } ]; @@ -63,6 +75,22 @@ const AccordionEvents = [ description: "Closed tab index" } ] + }, + { + name: "tab-click", + description: "Callback to invoke when an active tab is clicked.", + arguments: [ + { + name: "originalEvent", + type: "object", + description: "Original event" + }, + { + name: "index", + type: "number", + description: "Index of the clicked tab" + } + ] } ]; diff --git a/api-generator/components/accordiontab.js b/api-generator/components/accordiontab.js index 9a2fa4510..1f667a05c 100644 --- a/api-generator/components/accordiontab.js +++ b/api-generator/components/accordiontab.js @@ -5,6 +5,48 @@ const AccordionTabProps = [ default: "null", description: "Orientation of tab headers." }, + { + name: "headerStyle", + type: "any", + default: "null", + description: "Inline style of the tab header." + }, + { + name: "headerClass", + type: "any", + default: "null", + description: "Style class of the tab header." + }, + { + name: "headerProps", + type: "any", + default: "null", + description: "Uses to pass all properties of the HTMLDivElement to the tab header." + }, + { + name: "headerActionProps", + type: "any", + default: "null", + description: "Uses to pass all properties of the HTMLAnchorElement to the focusable anchor element inside the tab header." + }, + { + name: "contentStyle", + type: "any", + default: "null", + description: "Inline style of the tab content." + }, + { + name: "contentClass", + type: "any", + default: "null", + description: "Style class of the tab content." + }, + { + name: "contentProps", + type: "any", + default: "null", + description: "Uses to pass all properties of the HTMLDivElement to the tab content." + }, { name: "disabled", type: "boolean", diff --git a/src/components/accordion/Accordion.d.ts b/src/components/accordion/Accordion.d.ts index f70354ce2..f7f1ce06c 100755 --- a/src/components/accordion/Accordion.d.ts +++ b/src/components/accordion/Accordion.d.ts @@ -18,6 +18,11 @@ export interface AccordionTabOpenEvent { */ export interface AccordionTabCloseEvent extends AccordionTabOpenEvent { } +/** + * @extends AccordionTabOpenEvent + */ + export interface AccordionClickEvent extends AccordionTabOpenEvent { } + export interface AccordionProps { /** * When enabled, multiple tabs can be activated at the same time. @@ -39,6 +44,14 @@ export interface AccordionProps { * Icon of an expanded tab. */ collapseIcon?: string | undefined; + /** + * Index of the element in tabbing order. + */ + tabindex?: number | undefined; + /** + * When enabled, the focused tab is activated. + */ + selectOnFocus?: boolean | undefined; } export interface AccordionSlots { @@ -64,6 +77,11 @@ export declare type AccordionEmits = { * @param {AccordionTabCloseEvent} event - Custom tab close event. */ 'tab-close': (event: AccordionTabCloseEvent) => void; + /** + * Callback to invoke when an active tab is clicked. + * @param {AccordionClickEvent} event - Custom tab click event. + */ + 'tab-click': (event: AccordionClickEvent) => void; } declare class Accordion extends ClassComponent { } diff --git a/src/components/accordion/Accordion.vue b/src/components/accordion/Accordion.vue index 19f6d97a1..4134d9554 100755 --- a/src/components/accordion/Accordion.vue +++ b/src/components/accordion/Accordion.vue @@ -1,17 +1,18 @@