Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Accordion: add a class at the panel level to indicate open state #3419

Closed
davious opened this issue Mar 23, 2015 · 6 comments
Closed

Accordion: add a class at the panel level to indicate open state #3419

davious opened this issue Mar 23, 2015 · 6 comments

Comments

@davious
Copy link
Contributor

davious commented Mar 23, 2015

Would you add a class to indicate the panel is open at the panel level?

I'm using a caret indicator in the panel-title like so:

.panel-title > a:before { 
  content: $fa-var-angle-right;
  font: normal normal normal 14px/1 FontAwesome; }

.panel-open .panel-title > a:before {
  content: $fa-var-angle-down; }

Adding a class like panel-open on the panel div would allow me to just go like

<accordion-group is-open="thisDrawer.open">

instead of

<accordion-group is-open="thisDrawer.open" ng-class="{'panel-open': thisDrawer.open}">
@davious davious changed the title Accordion: add a class at the panel-level to indicate open state Accordion: add a class at the panel level to indicate open state Mar 23, 2015
@karianna karianna added this to the Backlog milestone Mar 23, 2015
@RobJacobs
Copy link
Contributor

This is a trivial change, simple as changing the template for the accordion-group to something like:

<div class="panel-heading" ng-class="{'panel-open': isOpen}">

My only concerns are:

  1. Adding another watch to the directive.
  2. Is the 'panel-open' class correct or should it just be 'open'.

@davious
Copy link
Contributor Author

davious commented Apr 11, 2015

@RobJacobs thanks for considering this.

For 1. would a broadcast and on be any better?
For 2. let's mimic bootstrap's use of [aria-expanded]

over on bootstrap's example
they have an aria-expanded = true/false attribute on a. We could mimic this in ui bootstrap.

the styling could then be:

.panel-title > a[aria-expanded]:before { 
  content: $fa-var-angle-right;
  font: normal normal normal 14px/1 FontAwesome; }

.panel-title > a[aria-expanded=true]:before {
  content: $fa-var-angle-down; }

@karianna karianna modified the milestones: 1.1, Backlog Apr 11, 2015
@icfantv
Copy link
Contributor

icfantv commented Aug 6, 2015

I would argue that using events for something like this is wrong. I would consider adding a class such that no actual CSS is tied to the name. The CSS class open is used by Bootstrap in a number of different ways and doesn't contain any actual styling by itself. Additionally, no pre-existing CSS exists for .open.panel-heading, .open > .panel-heading, or .open panel-heading.

I'm ok with this change. @RobJacobs do you want to create the PR or would you like me to?

@icfantv icfantv self-assigned this Aug 7, 2015
@icfantv
Copy link
Contributor

icfantv commented Aug 8, 2015

UPDATED the aria-expanded attribute is already set correctly by the collapse directive.

Just an update on this. Adding aria-expanded is not sufficient since aria is specifically for accessibility. The solution here should add aria-expanded="true" and open when open~~, and aria-expanded="false" when closed~~. Note that there is no closed equivalent in Bootstrap.

icfantv added a commit to icfantv/bootstrap that referenced this issue Aug 8, 2015
- add `open` class to `.panel-collapse` when open.
- fix missing closing `<` on test.

fixes angular-ui#3419
@wesleycho
Copy link
Contributor

I think this is ok - adding another two $watches is not the greatest, but this beats putting an ng-class on the accordion-group and it transcluding that so there are 4 $watches as a result.

@icfantv icfantv closed this as completed in ead15e3 Aug 8, 2015
@wesleycho wesleycho modified the milestones: 0.13.3 (Fixes), 1.1 (ARIA Accessibility) Aug 8, 2015
@blowsie
Copy link

blowsie commented Aug 12, 2015

This commit broke my page, I can no longer use ng-class on an accordion group

icfantv added a commit to icfantv/bootstrap that referenced this issue Aug 27, 2015
* updat breaking changes section to include angular-ui#3419
icfantv added a commit that referenced this issue Aug 28, 2015
* update breaking changes section to include #3419

Closes #4295
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants