Open btbunze opened 2 weeks ago
@btbunze a couple of notes:
exclusiveOpen
be set to true/false?<Accordion :open="2" />
or even
<Accordion :open="[1, 3]" />
to set mutliple.
@btbunze I had the same thought as Jake re: item #4. I definitely think we should include a state of which item is open/closed so we can link to a page with a particular item open.
@jakedohm re: item #2 is there ever an instance where we will have two items open? I'm thinking of an instance where we have the accordion set to only allow one item open at a time, but accidentally include multiple. Would we default to the first item in that array, o rhave the component fail so we can fix?
Thanks for the feedback, guys! 1: I was thinking false for all, but I'm open to suggestions otherwise. I don't think either case is going to be vastly more common than the other (for exclusiveOpen and scrollOnOpen), and I'd prefer to default to less magic
2/4: I don't necessarily think we need to give the parent full control (
3: Yeah, absolutely
@btbunze @DrewTJohnson For #4, I think maybe we could just use the browser's hash for this. So it won't store multiples, but if you click on the second accordion item, we do something like #accordion-3
in the URL so that the browser will auto-scroll to that element, and maybe in the component we check to see if the hash matches an item and if so, auto-open that item?
@jakedohm That's how we would handle Tabs to link to a specific tab, so I think going that way for the Accordion will make a nice standard for those types of elements.
Name of Component(s) Accordion Accordion Item
Filename(s) Accordion.vue AccordionItem.vue
Purpose Display information in coordinated, toggleable disclosures
Functionality
State
Props
defaultOpen - set which (if any) disclosures should be open by defaultContent Slots
Dependencies
Notes The state of a Disclosure is contained within and managed by itself, so I think the best way to coordinate the items is to watch the data-headlessui-state attribute for each and send necessary instructions to the disclosures when one changes. The alternative, having the Accordion keep track of the state of all its children, would mean keeping (and having to sync) state in multiple locations.