diff --git a/composites/Plugin/Shared/components/Collapsible.js b/composites/Plugin/Shared/components/Collapsible.js
index 93c82ded..b6242d6f 100644
--- a/composites/Plugin/Shared/components/Collapsible.js
+++ b/composites/Plugin/Shared/components/Collapsible.js
@@ -1,9 +1,11 @@
import PropTypes from "prop-types";
import React from "react";
import styled from "styled-components";
+import omit from "lodash/omit";
import colors from "../../../../style-guide/colors.json";
import { IconsButton } from "../../Shared/components/Button";
+import ScreenReaderText from "../../../../a11y/ScreenReaderText";
const StyledContainer = styled.div`
background-color: ${ colors.$color_white };
@@ -72,18 +74,19 @@ const StyledHeading = wrapInHeading( StyledIconsButton, 2 );
/**
* Base collapsible panel. Optionally has a heading around the button.
*
- * @param {object} props The properties for the component.
- * @param {children} props.children The content of the Collapsible.
- * @param {IconsButton} props.Heading Heading button. May be wrapped or styled or both.
- * @param {boolean} props.isOpen True displays the children. False means collapsed.
- * @param {function} props.onToggle Function to handle the Heading click event.
- * @param {string} props.prefixIcon Heading icon before the title.
- * @param {string} props.prefixIconCollapsed Prefix icon when in collapsed state.
- * @param {string} props.prefixIconColor CSS color of the prefix icon.
- * @param {string} props.suffixIcon Heading icon after the title.
- * @param {string} props.suffixIconColor CSS color of the suffix icon.
- * @param {string} props.suffixIconCollapsed Suffix icon when in collapsed state.
- * @param {string} props.title Title for in the Heading.
+ * @param {object} props The properties for the component.
+ * @param {children} props.children The content of the Collapsible.
+ * @param {IconsButton} props.Heading Heading button. May be wrapped or styled or both.
+ * @param {boolean} props.isOpen True displays the children. False means collapsed.
+ * @param {function} props.onToggle Function to handle the Heading click event.
+ * @param {string} props.prefixIcon Heading icon before the title.
+ * @param {string} props.prefixIconCollapsed Prefix icon when in collapsed state.
+ * @param {string} props.prefixIconColor CSS color of the prefix icon.
+ * @param {string} props.suffixIcon Heading icon after the title.
+ * @param {string} props.suffixIconColor CSS color of the suffix icon.
+ * @param {string} props.suffixIconCollapsed Suffix icon when in collapsed state.
+ * @param {string} props.title Title for in the Heading.
+ * @param {string} props.titleScreenReaderText Chance for an extra
*
* @returns {ReactElement} A collapsible panel.
*/
@@ -99,6 +102,7 @@ export const CollapsibleStateless = ( props ) => {
suffixIconColor={ props.suffixIconColor }
>
{ props.title }
+ { props.titleScreenReaderText ? { props.titleScreenReaderText } : null }
{ props.isOpen && props.children }
@@ -120,6 +124,7 @@ CollapsibleStateless.propTypes = {
suffixIconCollapsed: PropTypes.string,
suffixIconColor: PropTypes.string,
title: PropTypes.string,
+ titleScreenReaderText: PropTypes.string,
};
CollapsibleStateless.defaultProps = {
@@ -135,16 +140,17 @@ export class Collapsible extends React.Component {
/**
* The constructor.
*
- * @param {object} props The properties for the component.
- * @param {number} props.headingLevel Heading level: 1 for h1, 2 for h2, etc.
- * @param {boolean} props.initialIsOpen Determines if the initial isOpen state is open or closed.
- * @param {string} props.prefixIcon Heading icon before the title.
- * @param {string} props.prefixIconCollapsed Prefix icon when in collapsed state.
- * @param {string} props.prefixIconColor CSS color of the prefix icon.
- * @param {string} props.suffixIcon Heading icon after the title.
- * @param {string} props.suffixIconColor CSS color of the suffix icon.
- * @param {string} props.suffixIconCollapsed Suffix icon when in collapsed state.
- * @param {string} props.title Title for in the Heading.
+ * @param {object} props The properties for the component.
+ * @param {number} props.headingLevel Heading level: 1 for h1, 2 for h2, etc.
+ * @param {boolean} props.initialIsOpen Determines if the initial isOpen state is open or closed.
+ * @param {string} props.prefixIcon Heading icon before the title.
+ * @param {string} props.prefixIconCollapsed Prefix icon when in collapsed state.
+ * @param {string} props.prefixIconColor CSS color of the prefix icon.
+ * @param {string} props.suffixIcon Heading icon after the title.
+ * @param {string} props.suffixIconColor CSS color of the suffix icon.
+ * @param {string} props.suffixIconCollapsed Suffix icon when in collapsed state.
+ * @param {string} props.title Title for in the Heading.
+ * @param {string} props.titleScreenReaderText Chance for an extra
*
* @returns {ReactElement} Base collapsible panel.
*/
@@ -241,6 +247,7 @@ Collapsible.propTypes = {
suffixIconCollapsed: PropTypes.string,
suffixIconColor: PropTypes.string,
title: PropTypes.string,
+ titleScreenReaderText: PropTypes.string,
};
Collapsible.defaultProps = {
diff --git a/composites/Plugin/Shared/tests/CollapsibleTest.js b/composites/Plugin/Shared/tests/CollapsibleTest.js
index 1684ca11..5f8d61a9 100644
--- a/composites/Plugin/Shared/tests/CollapsibleTest.js
+++ b/composites/Plugin/Shared/tests/CollapsibleTest.js
@@ -97,4 +97,23 @@ describe( "CollapsibleStateless", () => {
onToggle();
expect( component.toJSON() ).toMatchSnapshot();
} );
+
+ it( "matches the snapshot with prefix seo icon and screen reader text", () => {
+ const component = renderer.create(
+ {} }
+ >
+ { content }
+
+ );
+
+ let tree = component.toJSON();
+ expect( tree ).toMatchSnapshot();
+ } );
} );
diff --git a/composites/Plugin/Shared/tests/__snapshots__/CollapsibleTest.js.snap b/composites/Plugin/Shared/tests/__snapshots__/CollapsibleTest.js.snap
index badeaa72..27c831d8 100644
--- a/composites/Plugin/Shared/tests/__snapshots__/CollapsibleTest.js.snap
+++ b/composites/Plugin/Shared/tests/__snapshots__/CollapsibleTest.js.snap
@@ -1478,3 +1478,190 @@ exports[`CollapsibleStateless matches the snapshot when it is opened and closed
+ Vivamus rutrum velit ut nunc dignissim vulputate.
+
+
+ In a purus quis leo dictum ultrices. Aenean commodo erat at pellentesque placerat.
+
+
+ Ut id ex efficitur risus suscipit fermentum.
+
+
+ Proin sed dolor neque. Vestibulum id leo ut ante luctus interdum sed ut sem.
+
+
+`;
From eb78edd2ededea3fa920ecab0368aed06a4abd69 Mon Sep 17 00:00:00 2001
From: Igor
Date: Thu, 12 Apr 2018 10:40:41 +0200
Subject: [PATCH 3/3] Fix the comment as per CR.
---
composites/Plugin/Shared/components/Collapsible.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/composites/Plugin/Shared/components/Collapsible.js b/composites/Plugin/Shared/components/Collapsible.js
index b6242d6f..9c4c3a5e 100644
--- a/composites/Plugin/Shared/components/Collapsible.js
+++ b/composites/Plugin/Shared/components/Collapsible.js
@@ -86,7 +86,7 @@ const StyledHeading = wrapInHeading( StyledIconsButton, 2 );
* @param {string} props.suffixIconColor CSS color of the suffix icon.
* @param {string} props.suffixIconCollapsed Suffix icon when in collapsed state.
* @param {string} props.title Title for in the Heading.
- * @param {string} props.titleScreenReaderText Chance for an extra
+ * @param {string} props.titleScreenReaderText Chance for an extra text to feed to a screenreader.
*
* @returns {ReactElement} A collapsible panel.
*/
@@ -150,7 +150,7 @@ export class Collapsible extends React.Component {
* @param {string} props.suffixIconColor CSS color of the suffix icon.
* @param {string} props.suffixIconCollapsed Suffix icon when in collapsed state.
* @param {string} props.title Title for in the Heading.
- * @param {string} props.titleScreenReaderText Chance for an extra
+ * @param {string} props.titleScreenReaderText Chance for an extra text to feed to a screenreader.
*
* @returns {ReactElement} Base collapsible panel.
*/