diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d7276719f2..86f686b4264 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/src/components/accordion/_accordion.scss b/src/components/accordion/_accordion.scss index 56272da640a..72ff9d07f8d 100644 --- a/src/components/accordion/_accordion.scss +++ b/src/components/accordion/_accordion.scss @@ -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 { @@ -24,6 +30,7 @@ ; } + $paddingSizes: ( xs: $euiSizeXS, s: $euiSizeS, diff --git a/src/components/accordion/_accordion_form.scss b/src/components/accordion/_accordion_form.scss index 04f6fde3dcb..58e87664f31 100644 --- a/src/components/accordion/_accordion_form.scss +++ b/src/components/accordion/_accordion_form.scss @@ -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; diff --git a/src/components/accordion/accordion.js b/src/components/accordion/accordion.js index 8f8b96ea888..a822e47d623 100644 --- a/src/components/accordion/accordion.js +++ b/src/components/accordion/accordion.js @@ -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() { @@ -112,7 +121,7 @@ export class EuiAccordion extends Component { className={buttonClasses} > - + {icon}