primefaces / primevue

Next Generation Vue UI Component Library
https://primevue.org
MIT License
9.74k stars 1.17k forks source link

Fieldset: toggle icon does not work if there is a legend slot #6144

Closed brian-izaki closed 1 month ago

brian-izaki commented 1 month ago

Describe the bug

When I use a fieldset and enable toggleable, and if I put a slot for the legend, the button to toggle does not show.

Reproducer

https://stackblitz.com/edit/primevue-4-ts-vite-issue-template-8wikdd?file=package.json

PrimeVue version

4.0.2

Vue version

3.x

Language

TypeScript

Build / Runtime

TypeScript

Browser(s)

Chrome

Steps to reproduce the behavior

No response

Expected behavior

Have the minus icon when have a custom legend slot in fieldset

avramz commented 1 month ago

You need to add the button (or whatever you'd like) yourself, legend slot has toggleCallback in it's scope, and you can use it like this: https://stackblitz.com/edit/primevue-4-ts-vite-issue-template-uzyqn6?file=src%2FApp.vue

Legend slot documentation: https://primevue.org/fieldset/#api.fieldset.slots.legend

brian-izaki commented 1 month ago

Thanks!! It's an option for me now.

But if I try to add the #toggleicon slot, its content does not show.

image

I updated the code in stackblitz, adding the #toggleicon slot https://stackblitz.com/edit/primevue-4-ts-vite-issue-template-8wikdd?file=src%2FApp.vue

avramz commented 1 month ago

I see. Based on the current Fieldset component implementation toggleicon slot is inside the legend slot, hence not existing if you provide your own.

If the template structure is to remain the same, collapsed should at the very least be in the legend slot scope, so we could easily update the icon (or something else). Documentation should also be updated.

As a workaround, you can implemment it like this: https://stackblitz.com/edit/primevue-4-ts-vite-issue-template-vnd5uj?file=src%2FApp.vue

I'd be happy to put a PR for this, if this is the desired direction cc @tugcekucukoglu