Skip to content

Commit

Permalink
Accordion needs a height calculation on mount (#816)
Browse files Browse the repository at this point in the history
* Accordion needs a height calculation on mount

* add focus ring, fix styling in accordion
  • Loading branch information
snide authored May 10, 2018
1 parent c0d1323 commit 3d76684
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

**Bug fixes**

- Fixes height calculation error on `EuiAccordion` when it starts loads in an open state. ([#816](https://github.com/elastic/eui/pull/816))
- Added aria-invalid labeling on `EuiFormRow` ([#777](https://github.com/elastic/eui/pull/799))
- Added aria-live labeling for `EuiToasts` ([#777](https://github.com/elastic/eui/pull/777))
- Added aria labeling requirements for `EuiBadge` , as well as a generic prop_type function `requiresAriaLabel` in `utils` to check for it. ([#777](https://github.com/elastic/eui/pull/777)) ([#802](https://github.com/elastic/eui/pull/802))
Expand Down
11 changes: 9 additions & 2 deletions src/components/accordion/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
text-align: left;
width: 100%;

&:hover, &:focus {
&:hover {
text-decoration: underline;
cursor: pointer;
}

&:focus {
background-color: $euiFocusBackgroundColor;
.euiAccordion__iconWrapper {
@include euiFocusRing;

color: $euiColorPrimary;
border-radius: $euiBorderRadius;
}
}

}

.euiAccordion__childWrapper {
Expand All @@ -24,6 +30,7 @@
;
}


$paddingSizes: (
xs: $euiSizeXS,
s: $euiSizeS,
Expand Down
11 changes: 0 additions & 11 deletions src/components/accordion/_accordion_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@
text-decoration: underline;
}
}

&:focus {
text-decoration: none;
background-color: transparent;

.euiAccordionForm__title {
text-decoration: underline;
background-color: $euiFocusBackgroundColor;
outline: solid $euiSizeXS / 2 $euiFocusBackgroundColor;
}
}
}
.euiAccordionForm {
border-top: $euiBorderThin;
Expand Down
17 changes: 13 additions & 4 deletions src/components/accordion/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,19 @@ export class EuiAccordion extends Component {
this.onToggle = this.onToggle.bind(this);
}

componentDidUpdate() {
const height = this.state.isOpen ? this.childContent.clientHeight: 0;
setChildContentHeight = () => {
requestAnimationFrame(() => {
const height = this.state.isOpen ? this.childContent.clientHeight: 0;
this.childWrapper.setAttribute('style', `height: ${height}px`);
});
}

this.childWrapper.setAttribute('style', `height: ${height}px`);
componentDidMount() {
this.setChildContentHeight();
}

componentDidUpdate() {
this.setChildContentHeight();
}

onToggle() {
Expand Down Expand Up @@ -112,7 +121,7 @@ export class EuiAccordion extends Component {
className={buttonClasses}
>
<EuiFlexGroup gutterSize="s" alignItems="center" responsive={false}>
<EuiFlexItem grow={false}>
<EuiFlexItem grow={false} className="euiAccordion__iconWrapper">
{icon}
</EuiFlexItem>

Expand Down

0 comments on commit 3d76684

Please sign in to comment.