Skip to content

Accordion#1357

Merged
matthewcarleton merged 19 commits intopatternfly:masterfrom
christiemolloy:accordian
Feb 14, 2019
Merged

Accordion#1357
matthewcarleton merged 19 commits intopatternfly:masterfrom
christiemolloy:accordian

Conversation

@christiemolloy
Copy link
Member

Closes #116.

@maryshak1996
Copy link

@christiemolloy do you have a link for it that I could take a look at? :)

@christiemolloy
Copy link
Member Author

@maryshak1996 just bumped the a11y count, hopefully it will pass!

@patternfly-build
Copy link
Collaborator

patternfly-build commented Feb 1, 2019

Deploy preview for pf-next ready!

Built with commit c51ad9b

https://deploy-preview-1357--pf-next.netlify.com

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@jgiardino
Copy link
Contributor

Great job with this one!

For comparison, I looked at these examples:

  • https://www.w3.org/TR/wai-aria-practices-1.1/examples/accordion/accordion.html
    • this one is kind of similar to your implementation, in that they use a <dl> where you use a <ul>. Since the panel contents can be anything, using a <dd> seems a little better suited than putting them inside the <li>.
  • https://inclusive-components.design/collapsible-sections/#state
    • I kind of like the simplicity of differentiating the sections using headings. For example, if we didn't have the expand/collapse feature, these contents would just be sections separated by headings.
    • The author of this one makes some interesting points about aria-controls not being needed in this type of component. His comments are consistent with feedback we received when testing, that if the controlled contents immediately follow the toggle, then they know by proximity that they're related.

Let me know what you think about these options. We can also bring this up during the a11y review meeting to let others weigh in.

@@ -0,0 +1,6 @@
<li class="pf-c-accordion__item{{#if accordion-item--IsExpanded}} pf-m-expanded{{/if}}{{#if accordion-item--modifier}} {{accordion-item--modifier}}{{/if}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aria-expanded attribute should always be placed on the interactive element. So in this case, it should be moved from the <li> to the button.pf-c-accordion__item-button.

@@ -0,0 +1,41 @@
{{#> accordion}}
{{#> accordion-item accordion-item--attribute='aria-expanded="false"'}}
{{#> accordion-item-button accordion-item-button--attribute='aria-controls="ex-content-1"'}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is an attribute that's suggested in the wai-aria example for Accordion, but I lean toward only using this attribute for cases where the controlled contents do not immediately follow the toggle. I'd suggest to just remove this attribute altogether.

@maryshak1996
Copy link

@christiemolloy this came out great!

@christiemolloy
Copy link
Member Author

@jgiardino thanks for your comments... I made the respective updates. I agree with everything you mentioned, so its up to you if you want to bring them up in the a11y meeting - but I don't think they're too controversial.

Copy link
Contributor

@matthewcarleton matthewcarleton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking solid Christie.
Was there any discussion what the buttons would look like with longer strings of text? Right now it just breaks to a second line.

@@ -0,0 +1,6 @@
<ul class="pf-c-accordion{{#if accordion--modifier}} {{accordion--modifier}}{{/if}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a <dl>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wai-aria example uses <dl> but when I test their implementation in VO, I don't get any of the semantics associated with <dl>. I'm not sure if that's because they change the role of <dt> to a heading or not, but doing that seems to render the use of <dl> kind of pointless.

This implementation is also missing the <dt> element, and it might be worth checking in a screen reader what happens when you nest all the toggle elements like this:
<dt><h2><button class="pf-c-accordion__item-button" aria-expanded="false">...
instead of follow what wai-aria does with
<dt role="heading" aria-level="3"><button aria-expanded="true" ...>...

But I think it would also be fine just use <div>s for both .pf-c-accordion and .pf-c-accordion__item in this implementation, especially if the nesting suggestion above doesn't produce anything more meaningful in the screen reader experience.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya I was wondering why we couldn't use <dt> in place of the <h2> if we are going with the <dl>, <dd> structure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this to use <dl> > <div> > <dt> > <dd> We have the extra div because of the blue border on the left, but I could try rearranging the CSS to style this border without?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya you might be able to just style the border of the <dt> and the expanded <dd> rather than having the wrapping div. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.pf-c-accordion-item as a <div> wrapper takes on accordion-item--IsExpanded and unassigns hidden to .pf-c-accordion-item-expanded-content. But that is because it is the parent of .pf-c-accordion-item-expanded-content . Without this div wrapper, .pf-c-accordion-item__button sits adjacent to .pf-c-accordion-item__expanded-contentand because they are siblings the expanded assignment doesn't work. However the wai-aria example uses js to toggle which item is hidden. So it seems to me that it needs this parent wrapper div to handle the expanded content in CSS. @matthewcarleton


.pf-c-accordion {
// accordion
--pf-c-accordion--Width: #{pf-size-prem(300px)};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is coming from the design but are we saying that accordions couldn't be a different width? It would seem more likely that they would set the accordion width in the layout. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Not sure we can always predict the width of an accordion as it would be driven by layout and content.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following the design, but I definitely agree that its layout should handle its width.

--pf-c-accordion--BackgroundColor: var(--pf-global--BackgroundColor--light-100);
--pf-c-accordion--BorderWidth: var(--pf-global--BorderWidth--sm);
--pf-c-accordion--BoxShadow: var(--pf-global--BoxShadow--md);
--pf-c-accordion--PaddingTop: var(--pf-global--spacer--lg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the design is calling for 32px here and the bottom.

.pf-c-accordion__item {
position: relative;

&::before {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried writing this so you aren't applying all these to every item when they are aren't expanded?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had seen this done in data list, and I assumed this way would avoid the accordion item jittering when it expanded... but when I write this the other way it makes no difference. I guess we should be consistent with this across the all of pf - what do you recommend @matthewcarleton

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's a more efficient way to write it, but maybe test it first to make sure 🤷‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay it doesnt make a difference to this component so im in favor of the more efficient way :)

| -- | -- | -- |
| `aria-expanded="false"` | `.pf-c-accordion__item` | Indicates that the expanded content element is hidden. **Required**|
| `aria-expanded="true"` | `.pf-c-accordion__item`, `.pf-c-accordion__item-expanded-content` | Indicates that the expanded content element is visible. **Required**|
| `hidden` | `.pf-c-accordion__item-expanded-content` | Indicates that the expanded content element is hidden.**Required** |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we clarify that this should be used with aria-expanded="false"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes


| Class | Applied To | Outcome |
| -- | -- | -- |
| `.pf-c-accordion` | `<ul>` | Initiates an accordion component. **Required**|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is going to be a <dl>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this to a <dl>

| Class | Applied To | Outcome |
| -- | -- | -- |
| `.pf-c-accordion` | `<ul>` | Initiates an accordion component. **Required**|
| `.pf-c-accordion__item` | `<li>` | Initiates a list item in the accordion component. **Required** |
Copy link
Contributor

@matthewcarleton matthewcarleton Feb 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a <dt>

@christiemolloy
Copy link
Member Author

@matthewcarleton left some comments - also when the buttons reach a longer length the string truncates at a width of 90% - what do you think about that, at a width of 100% it runs into the toggle arrow.

@matthewcarleton
Copy link
Contributor

@christiemolloy I think that works. The only issue I see is when it's much wider 90% leaves quite a bit of space. That may be irrelevant though. I think this could actually work in the dropdown too, but would have to test to see. nice!

Copy link
Contributor

@matthewcarleton matthewcarleton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Christie, this is looking really close. I made a few final comments. The only other thing I wonder about is how it's documented. We don't document the <dt> or the <h3> but both are required either for semantic reasons of accessibilities reasons. Do you think they should be added?

// This component always needs to be light
@include pf-t-light;

position: relative;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed

.pf-c-accordion__button-text {
width: var(--pf-c-accordion__button-text--width);
overflow: hidden;
text-align: left;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed

Copy link
Member Author

@christiemolloy christiemolloy Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I remove this it centers the content - its because of the width placed on the text when it truncates. so changed width to max-width

--pf-c-accordion__button--hover--BackgroundColor: var(--pf-global--BackgroundColor--150);
--pf-c-accordion__button--focus--BackgroundColor: var(--pf-global--BackgroundColor--150);
--pf-c-accordion__button--active--BackgroundColor: var(--pf-global--BackgroundColor--150);
--pf-c-accordion__button--m-expanded--before--ZIndex: var(--pf-global--ZIndex--xl);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed


| Class | Applied To | Outcome |
| -- | -- | -- |
| `.pf-c-accordion` | `<ul>` | Initiates an accordion component. **Required**|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this to a <dl>

| `.pf-c-accordion__button-text` | `<span>` | Initiates the text inside the button. **Required** |
| `.pf-c-accordion__button-toggle` | `<span>` | Initiates the toggle inside the button. **Required** |
| `.pf-c-accordion__button-toggle-icon` | `<i>` | Initiates the toggle icon inside the toggle. **Required** |
| `.pf-c-accordion__expanded-content` | `<div>` | Initiates an expanded content. **Must be paired with a button** |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a <dd>

{{#if accordion-expanded-content--attribute}}
{{{accordion-expanded-content--attribute}}}
{{/if}}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis molestie lorem lacinia dolor aliquet faucibus. Suspendisse gravida imperdiet accumsan. Aenean auctor lorem justo, vitae tincidunt enim blandit vel. Aenean quis tempus dolor. Lorem ipsum dolor sit amet, consectetur adipiscing elit Bla Bla Blee Bla.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this out of here and into the examples. That way you can add extra content for the fixed example to show how it scrolls.

@@ -0,0 +1,6 @@
<div class="pf-c-accordion__item{{#if accordion-item--IsExpanded}} pf-m-expanded{{/if}}{{#if accordion-item--modifier}} {{accordion-item--modifier}}{{/if}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this file.

@@ -0,0 +1,7 @@
<span class="pf-c-accordion__button-toggle{{#if accordion__button-toggle--modifier}} {{accordion__button-toggle--modifier}}{{/if}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why you can't just have the .pf-c-accordion__button-toggle-icon ? I'd say we can take the same approach here as we do in the dropdown where we just use an icon and not need the wrapper.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep you're right!

@christiemolloy
Copy link
Member Author

thanks @matthewcarleton made updates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants