diff --git a/api-generator/components/fieldset.js b/api-generator/components/fieldset.js index 27447d00f..e59469918 100644 --- a/api-generator/components/fieldset.js +++ b/api-generator/components/fieldset.js @@ -17,6 +17,12 @@ const FieldsetProps = [ type: "boolean", default: "true", description: "Defines the default visibility state of the content." + }, + { + name: "toggleButtonProps", + type: "string", + default: "null", + description: "Uses to pass the custom value to read for the anchor inside the component." } ]; diff --git a/src/components/fieldset/Fieldset.d.ts b/src/components/fieldset/Fieldset.d.ts index 486f0757f..6af83cec1 100755 --- a/src/components/fieldset/Fieldset.d.ts +++ b/src/components/fieldset/Fieldset.d.ts @@ -25,6 +25,10 @@ export interface FieldsetProps { * Defines the default visibility state of the content. */ collapsed?: boolean | undefined; + /** + * Uses to pass the custom value to read for the anchor inside the component. + */ + toggleButtonProps?: string | undefined; } export interface FieldsetSlots { diff --git a/src/components/fieldset/Fieldset.vue b/src/components/fieldset/Fieldset.vue index ca8feaa4a..8d4f71feb 100755 --- a/src/components/fieldset/Fieldset.vue +++ b/src/components/fieldset/Fieldset.vue @@ -4,8 +4,8 @@ {{legend}} - + {{legend}} @@ -13,8 +13,7 @@ -
+
@@ -33,11 +32,12 @@ export default { props: { legend: String, toggleable: Boolean, - collapsed: Boolean + collapsed: Boolean, + toggleButtonProps: String }, data() { return { - d_collapsed: this.collapsed + d_collapsed: this.collapsed } }, watch: { @@ -53,6 +53,12 @@ export default { originalEvent: event, value: this.d_collapsed }); + }, + onKeyDown(event) { + if (event.code === 'Enter' || event.code === 'Space') { + this.toggle(event); + event.preventDefault(); + } } }, computed: { diff --git a/src/views/fieldset/FieldsetDemo.vue b/src/views/fieldset/FieldsetDemo.vue index 3a95a3ba9..df415cc4f 100755 --- a/src/views/fieldset/FieldsetDemo.vue +++ b/src/views/fieldset/FieldsetDemo.vue @@ -19,7 +19,7 @@
Toggleable
-
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat diff --git a/src/views/fieldset/FieldsetDoc.vue b/src/views/fieldset/FieldsetDoc.vue index 4214f152a..d77b36572 100755 --- a/src/views/fieldset/FieldsetDoc.vue +++ b/src/views/fieldset/FieldsetDoc.vue @@ -97,6 +97,12 @@ import Fieldset from 'primevue/fieldset'; boolean null Defines the default visibility state of the content. + + + toggleButtonProps + string + null + Uses to pass the custom value to read for the anchor inside the component. @@ -154,25 +160,64 @@ import Fieldset from 'primevue/fieldset'; - fieldset + p-fieldset Fieldset element. - fieldset-toggleable + p-fieldset-toggleable Toggleable fieldset element. - fieldset-legend + p-fieldset-legend Legend element. - fieldset-content + p-fieldset-content Content element.

+
Accessibility
+ +
Screen Reader
+

Fieldset component uses the semantic fieldset element. When toggleable option is enabled, a clickable element with button role is included inside the legend element, this button + has aria-controls to define the id of the content section along with aria-expanded for the visibility state. The value to read the button + defaults to the value of the legend property and can be customized by defining an aria-label or aria-labelledby via the toggleButtonProps property.

+

The content uses region, defines an id that matches the aria-controls of the content toggle button and aria-labelledby referring to the id of the header.

+ +
Content Toggle Button Keyboard Support
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
KeyFunction
tabMoves focus to the next the focusable element in the page tab sequence.
shift + tabMoves focus to the previous the focusable element in the page tab sequence.
enterToggles the visibility of the content.
spaceToggles the visibility of the content.
+
+
+
Dependencies

None.