Skip to content

Commit

Permalink
Fixed #3288 - Fieldset: toggleButtonProps prop defect
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Nov 17, 2022
1 parent 70b8912 commit 6665952
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/fieldset/Fieldset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface FieldsetProps {
/**
* Uses to pass the custom value to read for the anchor inside the component.
*/
toggleButtonProps?: string | undefined;
toggleButtonProps?: object | undefined;
}

export interface FieldsetSlots {
Expand Down
22 changes: 20 additions & 2 deletions src/components/fieldset/Fieldset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
<slot v-if="!toggleable" name="legend">
<span :id="ariaId + '_header'" class="p-fieldset-legend-text">{{ legend }}</span>
</slot>
<a v-if="toggleable" :id="ariaId + '_header'" v-ripple tabindex="0" role="button" :aria-controls="ariaId + '_content'" :aria-expanded="!d_collapsed" :aria-label="toggleButtonProps || legend" @click="toggle" @keydown="onKeyDown">
<a
v-if="toggleable"
:id="ariaId + '_header'"
v-ripple
tabindex="0"
role="button"
:aria-controls="ariaId + '_content'"
:aria-expanded="!d_collapsed"
:aria-label="buttonAriaLabel"
@click="toggle"
@keydown="onKeyDown"
v-bind="toggleButtonProps"
>
<span :class="iconClass"></span>
<slot name="legend">
<span class="p-fieldset-legend-text">{{ legend }}</span>
Expand Down Expand Up @@ -32,7 +44,10 @@ export default {
legend: String,
toggleable: Boolean,
collapsed: Boolean,
toggleButtonProps: String
toggleButtonProps: {
type: null,
default: null
}
},
data() {
return {
Expand Down Expand Up @@ -72,6 +87,9 @@ export default {
},
ariaId() {
return UniqueComponentId();
},
buttonAriaLabel() {
return this.toggleButtonProps && this.toggleButtonProps['aria-label'] ? this.toggleButtonProps['aria-label'] : this.legend;
}
},
directives: {
Expand Down
2 changes: 1 addition & 1 deletion src/views/fieldset/FieldsetDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ import Fieldset from 'primevue/fieldset';
</tr>
<tr>
<td>toggleButtonProps</td>
<td>string</td>
<td>object</td>
<td>null</td>
<td>Uses to pass the custom value to read for the anchor inside the component.</td>
</tr>
Expand Down

0 comments on commit 6665952

Please sign in to comment.