diff --git a/docs/app/Examples/modules/Dropdown/Content/DropdownExampleDescription.js b/docs/app/Examples/modules/Dropdown/Content/DropdownExampleDescription.js index e8df1b2845..62162d7ed1 100644 --- a/docs/app/Examples/modules/Dropdown/Content/DropdownExampleDescription.js +++ b/docs/app/Examples/modules/Dropdown/Content/DropdownExampleDescription.js @@ -2,13 +2,12 @@ import React from 'react' import { Dropdown } from 'semantic-ui-react' const DropdownExampleDescription = () => ( - - {/* */} + - + diff --git a/src/modules/Dropdown/DropdownItem.js b/src/modules/Dropdown/DropdownItem.js index 806677b07d..dc4f45629f 100644 --- a/src/modules/Dropdown/DropdownItem.js +++ b/src/modules/Dropdown/DropdownItem.js @@ -138,22 +138,16 @@ export default class DropdownItem extends Component { const labelElement = Label.create(label) const descriptionElement = createShorthand( 'span', - val => ({ className: 'description', children: val }), + val => ({ children: val }), description, + props => ({ className: 'description' }) + ) + const textElement = createShorthand( + 'span', + val => ({ children: val }), + content || text, + props => ({ className: 'text' }) ) - - if (descriptionElement) { - return ( - - {imageElement} - {iconElement} - {flagElement} - {labelElement} - {descriptionElement} - {createShorthand('span', val => ({ className: 'text', children: val }), content || text)} - - ) - } return ( @@ -161,7 +155,8 @@ export default class DropdownItem extends Component { {iconElement} {flagElement} {labelElement} - {content || text} + {descriptionElement} + {textElement} ) } diff --git a/test/specs/elements/Image/Image-test.js b/test/specs/elements/Image/Image-test.js index c515004cb7..8263e42cda 100644 --- a/test/specs/elements/Image/Image-test.js +++ b/test/specs/elements/Image/Image-test.js @@ -7,7 +7,7 @@ import { SUI } from 'src/lib' import Dimmer from 'src/modules/Dimmer/Dimmer' import * as common from 'test/specs/commonTests' -describe('Image Component', () => { +describe('Image', () => { common.isConformant(Image) common.hasSubComponents(Image, [ImageGroup]) common.hasUIClassName(Image) diff --git a/test/specs/modules/Dropdown/Dropdown-test.js b/test/specs/modules/Dropdown/Dropdown-test.js index 5a607cdefc..52a70b43c6 100644 --- a/test/specs/modules/Dropdown/Dropdown-test.js +++ b/test/specs/modules/Dropdown/Dropdown-test.js @@ -56,7 +56,7 @@ const dropdownMenuIsOpen = () => { const nativeEvent = { nativeEvent: { stopImmediatePropagation: _.noop } } -describe('Dropdown Component', () => { +describe('Dropdown', () => { beforeEach(() => { attachTo = undefined wrapper = undefined @@ -769,12 +769,12 @@ describe('Dropdown Component', () => { const nextItem = _.sample(_.without(options, initialItem)) wrapperMount() - .find('.text') + .find('div.text') .should.contain.text(initialItem.text) wrapper .setProps({ value: nextItem.value }) - .find('.text') + .find('div.text') .should.contain.text(nextItem.text) }) }) @@ -784,7 +784,7 @@ describe('Dropdown Component', () => { const text = faker.hacker.phrase() wrapperRender() - .find('.text') + .find('div.text') .should.contain.text(text) }) it('prevents updates on item click if defined', () => { @@ -797,7 +797,7 @@ describe('Dropdown Component', () => { .simulate('click') wrapper - .find('.text') + .find('div.text') .should.contain.text(text) }) it('is updated on item click if not already defined', () => { @@ -814,7 +814,7 @@ describe('Dropdown Component', () => { // text updated wrapper - .find('.text') + .find('div.text') .should.contain.text(item.text()) }) it('displays if value is 0', () => { @@ -832,10 +832,10 @@ describe('Dropdown Component', () => { // text updated wrapper - .find('.text') + .find('div.text') .should.contain.text(item.text()) }) - it('does not display if value is \'\'', () => { + it("does not display if value is ''", () => { const text = faker.hacker.noun() wrapperMount() @@ -844,7 +844,7 @@ describe('Dropdown Component', () => { .simulate('click') wrapper - .find('.text') + .find('div.text') .should.contain.text('') }) it('does not display if value is null', () => { @@ -856,7 +856,7 @@ describe('Dropdown Component', () => { .simulate('click') wrapper - .find('.text') + .find('div.text') .should.contain.text('') }) it('does not display if value is undefined', () => { @@ -868,7 +868,7 @@ describe('Dropdown Component', () => { .simulate('click') wrapper - .find('.text') + .find('div.text') .should.contain.text('') }) }) @@ -887,7 +887,7 @@ describe('Dropdown Component', () => { const trigger =
{text}
wrapperRender() - .should.not.have.descendants('.text') + .should.not.have.descendants('div.text') }) }) diff --git a/test/specs/modules/Dropdown/DropdownItem-test.js b/test/specs/modules/Dropdown/DropdownItem-test.js index 53d78e54d8..e53841e3ab 100644 --- a/test/specs/modules/Dropdown/DropdownItem-test.js +++ b/test/specs/modules/Dropdown/DropdownItem-test.js @@ -20,16 +20,21 @@ describe('DropdownItem', () => { common.implementsShorthandProp(DropdownItem, { propKey: 'flag', ShorthandComponent: Flag, - mapValueToProps: val => ({ name: val }), + mapValueToProps: name => ({ name }), }) common.implementsShorthandProp(DropdownItem, { propKey: 'description', ShorthandComponent: 'span', - mapValueToProps: val => ({ - className: 'description', - children: val, - }), + mapValueToProps: children => ({ children }), + shorthandDefaultProps: props => ({ className: 'description' }), + }) + + common.implementsShorthandProp(DropdownItem, { + propKey: 'text', + ShorthandComponent: 'span', + mapValueToProps: children => ({ children }), + shorthandDefaultProps: props => ({ className: 'text' }), }) describe('aria', () => { @@ -71,19 +76,17 @@ describe('DropdownItem', () => { }) }) - describe('text', () => { - it('renders with wrapping span when description', () => { - const wrapper = shallow() - - wrapper.should.have.descendants('span.text') - wrapper.text().should.include('hey') + describe('description', () => { + it('adds className="description" to element shorthand', () => { + shallow(} />) + .should.have.descendants('strong.description') }) + }) - it('renders without wrapping span when no description', () => { - const wrapper = shallow() - - wrapper.should.not.have.descendants('span.text') - wrapper.text().should.equal('hey') + describe('text', () => { + it('adds className="text" to element shorthand', () => { + shallow(} />) + .should.have.descendants('strong.text') }) }) diff --git a/test/specs/modules/Search/Search-test.js b/test/specs/modules/Search/Search-test.js index 179f0760b6..4b11e49bd7 100644 --- a/test/specs/modules/Search/Search-test.js +++ b/test/specs/modules/Search/Search-test.js @@ -63,7 +63,7 @@ const openSearchResults = () => { const nativeEvent = { nativeEvent: { stopImmediatePropagation: _.noop } } -describe('Search Component', () => { +describe('Search', () => { beforeEach(() => { attachTo = undefined wrapper = undefined