Skip to content
This repository was archived by the owner on Aug 7, 2020. It is now read-only.

Conversation

ganeshkumar1989
Copy link
Contributor

@ganeshkumar1989 ganeshkumar1989 commented Apr 25, 2018

UU-836
Collapsible component added.

Linked to
ovh/ovh-ui-kit#197
ovh-ux/ovh-ui-kit-documentation#94


this.$attrs = $attrs;
this.$element = $element;
this.$timeout = $timeout;
Copy link
Contributor

Choose a reason for hiding this comment

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

this.$element and this.$timeout are not used. We can remove them.
But we still need this.$attrs for addBooleanParameter`addBooleanParameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now the component accepts an id, which is required for aria-controls attribute. This id must be removed from the original directive and hence these dependencies are now required :)

<div class="oui-collapsible" data-ng-class="{'oui-collapsible_open':$ctrl.expanded}">
<div class="oui-collapsible__header" data-ng-click="$ctrl.toggle()">
<div class="oui-collapsible__header-text" data-ng-bind="::$ctrl.title"></div>
<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 <button> seems useless since the click is on the parent <div>.
What do you think about replacing oui-collapsible__header by a <button> ?

<button class="oui-collapsible__header" type="button"
    aria-label="{{::$ctrl.ariaLabel}}" aria-expanded="{{$ctrl.expanded}}"
    ng-click="$ctrl.toggle()">
    <span class="oui-collapsible__header-text" ng-bind="::$ctrl.title"></span>
    <span class="oui-icon oui-icon-chevron-down oui-collapsible__toggle-icon" aria-hidden="true"></span>
</button>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a very good idea :)
Expanding a panel on button click sounds good. But is having a button as a header a good idea? Please let me know your thoughts on this.
Another possibility is to remove the button and have the icon in oui-collapsible__header

Copy link
Contributor

Choose a reason for hiding this comment

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

For me, it's not a problem, as long as we don't have a click on a unfocusable tag.
We could still have a wrapper around the button if necessary, but you'll need the aria-controls attribute for a11y:
eg.

<div class="oui-collapsible__header">
    <button class="oui-collapsible__header-button" type="button"
        aria-label="{{::$ctrl.ariaLabel}}" 
        aria-expanded="{{$ctrl.expanded}}"
        aria-controls="collapsibleContent1"
        ng-click="$ctrl.toggle()">
        <span class="oui-collapsible__header-text" ng-bind="::$ctrl.title"></span>
        <span class="oui-icon oui-icon-chevron-down oui-collapsible__toggle-icon" aria-hidden="true"></span>
    </button>
</div>
<div class="oui-collapsible__body" id="collapsibleContent1">
    [...]
</div>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. After some thought, it seems like a button for the header is a better idea. I have done this change :)
Thanks again for this idea

@@ -0,0 +1,13 @@
<div class="oui-collapsible" data-ng-class="{'oui-collapsible_open':$ctrl.expanded}">
<div class="oui-collapsible__header" data-ng-click="$ctrl.toggle()">
Copy link
Contributor

Choose a reason for hiding this comment

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

Accessibility issue: we have no clue when the header has the focus (tab navigation).
We could add an outline like on the navbar for this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done :)

@@ -0,0 +1,13 @@
<div class="oui-collapsible" data-ng-class="{'oui-collapsible_open':$ctrl.expanded}">
Copy link
Contributor

Choose a reason for hiding this comment

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

Unlike in our managers, we don't prefixing with data- in our templates

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The data- prefix has now been removed :)

<i class="oui-icon oui-icon-chevron-down oui-collapsible__toggle-icon" aria-hidden="true"></i>
</button>
</div>
<div class="oui-collapsible__body" data-ng-transclude></div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Accessibility issue: we have no aria-expanded and aria-controls.
Please see here for more informations :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These attrs have been added

<button
type="button"
aria-label="{{::$ctrl.ariaLabel}}"
aria-pressed="{{$ctrl.expanded}}"
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 should be aria-expanded instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been changed :)

@ganeshkumar1989 ganeshkumar1989 changed the base branch from master to develop May 21, 2018 05:34
@AxelPeter AxelPeter force-pushed the feature/oui-collapsible branch from c122951 to b7adf2d Compare May 31, 2018 11:22
@AxelPeter AxelPeter deleted the feature/oui-collapsible branch June 4, 2018 12:09
neolitec pushed a commit that referenced this pull request Jun 21, 2018
* feat(oui-collapsible): collapsible component addition

* fix(oui-collapsible): example update

* fix(oui-collapsible): code clean-up

* fix(oui-collapsible): accessibility fixes

* fix(oui-collapsible): header replaced with button

* fix(oui-collapsible): fix test and update readme

* fix(oui-collapsible): fix collapse animation
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

4 participants