Skip to content

Commit

Permalink
fix(Sidebar): fix a collision between children and shorthand props (#…
Browse files Browse the repository at this point in the history
…4145)

* fix(Sidebar): fix a collision between `children` and shorthand props

* remove only

* fix test
  • Loading branch information
layershifter committed Jan 19, 2021
1 parent cb4b05e commit 89ba138
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
7 changes: 7 additions & 0 deletions cypress/integration/Sidebar/Sidebar.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/// <reference types="cypress" />

describe('Sidebar: spec', () => {
it('with a Menu', () => {
cy.visit('/maximize/sidebar-and-menu/')

cy.get('[data-tid="menu"]').should('be.visible')
cy.get('[data-tid="menu-item"]').should('be.visible')
})

it('with a Modal', () => {
cy.visit('/maximize/sidebar-and-modal/')

Expand Down
19 changes: 19 additions & 0 deletions docs/src/examples/modules/Sidebar/Spec/SidebarAndMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import { Menu, Sidebar } from 'semantic-ui-react'

const SidebarAndMenu = () => (
<Sidebar
as={Menu}
animation='push'
data-tid='menu'
inverted
items={[
{ key: 'home', content: 'Home', 'data-tid': 'menu-item' },
{ key: 'about', content: 'About' },
]}
vertical
visible
/>
)

export default SidebarAndMenu
18 changes: 10 additions & 8 deletions src/modules/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ class Sidebar extends Component {
const targetProp = isRefObject(target) ? { targetRef: target } : { target }

return (
<Ref innerRef={this.ref}>
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
{visible && (
<EventListener listener={this.handleDocumentClick} type='click' {...targetProp} />
)}
</ElementType>
</Ref>
<>
<Ref innerRef={this.ref}>
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
</Ref>
{visible && (
<EventListener listener={this.handleDocumentClick} type='click' {...targetProp} />
)}
</>
)
}
}
Expand Down
1 change: 1 addition & 0 deletions test/specs/modules/Transition/TransitionGroup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const wrapperShallow = (...args) => (wrapper = shallow(...args))
describe('TransitionGroup', () => {
common.isConformant(TransitionGroup, {
rendersFragmentByDefault: true,
rendersChildren: false,
})

beforeEach(() => {
Expand Down
5 changes: 5 additions & 0 deletions test/utils/nestedShallow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Ref } from '@fluentui/react-component-ref'
import enzyme from 'enzyme'
import _ from 'lodash'
import React from 'react'

const diveToLevel = (wrapper, autoNesting, nestingLevel) => {
let nestedWrapper = wrapper

if (autoNesting && nestedWrapper.is(React.Fragment)) {
nestedWrapper = nestedWrapper.childAt(0)
}

if (autoNesting && nestedWrapper.is(Ref)) {
nestedWrapper = nestedWrapper.childAt(0)
}
Expand Down

0 comments on commit 89ba138

Please sign in to comment.