department-of-veterans-affairs / vets-design-system-documentation

Repository for design.va.gov website
https://design.va.gov
37 stars 57 forks source link

[bug] `va-accordion` expand/collapse all button visibility #1118

Open Mottie opened 2 years ago

Mottie commented 2 years ago

Bug Report

What happened

I found 2 minor issues with the va-accordion web component.

Codesandbox demo showing the issues described above

What I expected to happen

Hide the "Expand all"/"Collapse all" button when one, or less, va-accordion-item are visible within the wrapper

Reproducing

Steps to reproduce:

  1. In the codesandbox demo, toggle the checkbox that shows and hides the va-accordion-item
  2. Note that the "Expand all"/"Collapse all" button is always visible
k80bowman commented 2 years ago

In the Slack thread on this support issue, @bkjohnson noted that he thought we had some guidance saying that an accordion should have two or more items, but it doesn't seem to be currently in our guidance.

@GnatalieH or @humancompanion-usds, do you have any thoughts on this?

GnatalieH commented 2 years ago

@k80bowman I also believe we should update our guidance to say that accordions should always have two or more items. If someone needs a single expandable content element, they can use Additional info. CC @humancompanion-usds

humancompanion-usds commented 2 years ago

@Mottie - Can you point us to the instance of a single accordion so I can have a look? Thanks.

Neither we nor USWDS have guidance around a minimum number of Accordions one has to have. I've used single accordions in the past (though I did not have an Additional Info component). I can imagine a use case for a single accordion given that it has much more visual presence than Additional info. Regardless, the 2nd issue mentioned still sounds like a bug either way.

Mottie commented 2 years ago

https://staging.va.gov/decision-reviews/higher-level-review/#find-addresses-for-other-benef-8622

bkjohnson commented 2 years ago

Since that template is setting data-multiselectable based on a CMS value, a quick fix could be to add the open-single prop to the accordion if entity.fieldCollapsiblePanelMulti is false.

A screenshot of Mottie's link above with the brower's inspector open. The markup representing the accordion is in view, and the `data-multiselectable` attribute on a wrapping container reads "false".

The "Expand all" button isn't added if openSingle is truthy.

A screenshot of an accordion story in storybook. The component has the `open-single` prop, and the "Expand all" button is absent.