From 7da1dd029471f653bac513661d27ac5092ef523d Mon Sep 17 00:00:00 2001 From: Priya Ranjan Singh Date: Mon, 25 Jun 2018 23:32:59 +0200 Subject: [PATCH 1/7] docs (Search): update layout for search example to accommodate code (#2948) Fake data used in a pre tag in search example makes content overflow & leaves a place for improvement. The example at SUI doesn't face such problems because the state is not displayed in examples. --- .../Search/Types/SearchExampleCategory.js | 12 +++++++----- .../Search/Types/SearchExampleStandard.js | 16 +++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/src/examples/modules/Search/Types/SearchExampleCategory.js b/docs/src/examples/modules/Search/Types/SearchExampleCategory.js index 8e97fef3dd..fd6527c0ab 100644 --- a/docs/src/examples/modules/Search/Types/SearchExampleCategory.js +++ b/docs/src/examples/modules/Search/Types/SearchExampleCategory.js @@ -1,7 +1,7 @@ import _ from 'lodash' import faker from 'faker' import React, { Component } from 'react' -import { Search, Grid, Header } from 'semantic-ui-react' +import { Search, Grid, Header, Segment } from 'semantic-ui-react' const getResults = () => _.times(5, () => ({ @@ -76,10 +76,12 @@ export default class SearchExampleCategory extends Component { /> -
State
-
{JSON.stringify(this.state, null, 2)}
-
Options
-
{JSON.stringify(source, null, 2)}
+ +
State
+
{JSON.stringify(this.state, null, 2)}
+
Options
+
{JSON.stringify(source, null, 2)}
+
) diff --git a/docs/src/examples/modules/Search/Types/SearchExampleStandard.js b/docs/src/examples/modules/Search/Types/SearchExampleStandard.js index 2569517388..7d5fe3d8fb 100644 --- a/docs/src/examples/modules/Search/Types/SearchExampleStandard.js +++ b/docs/src/examples/modules/Search/Types/SearchExampleStandard.js @@ -1,7 +1,7 @@ import _ from 'lodash' import faker from 'faker' import React, { Component } from 'react' -import { Search, Grid, Header } from 'semantic-ui-react' +import { Search, Grid, Header, Segment } from 'semantic-ui-react' const source = _.times(5, () => ({ title: faker.company.companyName(), @@ -40,7 +40,7 @@ export default class SearchExampleStandard extends Component { return ( - + - -
State
-
{JSON.stringify(this.state, null, 2)}
-
Options
-
{JSON.stringify(source, null, 2)}
+ + +
State
+
{JSON.stringify(this.state, null, 2)}
+
Options
+
{JSON.stringify(source, null, 2)}
+
) From 02af086cab3a1be14356047c6817623d775f1caa Mon Sep 17 00:00:00 2001 From: Alexander Fedyashov Date: Tue, 26 Jun 2018 00:34:03 +0300 Subject: [PATCH 2/7] fix(Icon): fix handling of aria-label (#2947) * fix(Icon): fix handling of aria-label Signed-off-by: Oleksandr Fediashov * fix(Icon): fix handling of aria-label Signed-off-by: Oleksandr Fediashov --- src/elements/Icon/Icon.d.ts | 3 +++ src/elements/Icon/Icon.js | 13 +++++++++++-- test/specs/elements/Icon/Icon-test.js | 27 ++++++++++++++++++++++----- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/elements/Icon/Icon.d.ts b/src/elements/Icon/Icon.d.ts index 7925da2cc9..76010beee6 100644 --- a/src/elements/Icon/Icon.d.ts +++ b/src/elements/Icon/Icon.d.ts @@ -53,6 +53,9 @@ export interface IconProps { /** Size of the icon. */ size?: IconSizeProp + /** Icon can have an aria hidden. */ + 'aria-hidden'?: string + /** Icon can have an aria label. */ 'aria-label'?: string } diff --git a/src/elements/Icon/Icon.js b/src/elements/Icon/Icon.js index c17fee5bbb..3010e74eaa 100644 --- a/src/elements/Icon/Icon.js +++ b/src/elements/Icon/Icon.js @@ -66,6 +66,9 @@ class Icon extends Component { /** Size of the icon. */ size: PropTypes.oneOf(_.without(SUI.SIZES, 'medium')), + /** Icon can have an aria label. */ + 'aria-hidden': PropTypes.string, + /** Icon can have an aria label. */ 'aria-label': PropTypes.string, } @@ -82,10 +85,16 @@ class Icon extends Component { getIconAriaOptions() { const ariaOptions = {} - const { 'aria-label': ariaLabel } = this.props + const { 'aria-label': ariaLabel, 'aria-hidden': ariaHidden } = this.props - if (!ariaLabel) { + if (_.isNil(ariaLabel)) { ariaOptions['aria-hidden'] = 'true' + } else { + ariaOptions['aria-label'] = ariaLabel + } + + if (!_.isNil(ariaHidden)) { + ariaOptions['aria-hidden'] = ariaHidden } return ariaOptions diff --git a/test/specs/elements/Icon/Icon-test.js b/test/specs/elements/Icon/Icon-test.js index ec26ba6e4e..b3b5494a8b 100644 --- a/test/specs/elements/Icon/Icon-test.js +++ b/test/specs/elements/Icon/Icon-test.js @@ -32,17 +32,34 @@ describe('Icon', () => { shallow().should.have.tagName('i') }) - describe('aria', () => { - it('should add aria-hidden to icon', () => { - const wrapper = shallow() + describe('aria-hidden', () => { + it('should add aria-hidden by default', () => { + shallow().should.have.prop('aria-hidden', 'true') + }) + + it('should pass aria-hidden', () => { + shallow(