Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the popover component using React Hooks #15053

Merged
merged 5 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`URLPopover matches the snapshot in its default state 1`] = `
<Popover
className="editor-url-popover block-editor-url-popover"
focusOnMount="firstElement"
noArrow={false}
position="bottom center"
>
<div
Expand All @@ -28,7 +27,6 @@ exports[`URLPopover matches the snapshot when the settings are toggled open 1`]
<Popover
className="editor-url-popover block-editor-url-popover"
focusOnMount="firstElement"
noArrow={false}
position="bottom center"
>
<div
Expand Down Expand Up @@ -59,7 +57,6 @@ exports[`URLPopover matches the snapshot when there are no settings 1`] = `
<Popover
className="editor-url-popover block-editor-url-popover"
focusOnMount="firstElement"
noArrow={false}
position="bottom center"
>
<div
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/dropdown-menu/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Component } from '@wordpress/element';
* Internal dependencies
*/
import DropdownMenu from '../';
import Popover from '../../popover';

describe( 'DropdownMenu', () => {
let controls;
Expand Down Expand Up @@ -79,7 +78,7 @@ describe( 'DropdownMenu', () => {
}
);

expect( TestUtils.scryRenderedComponentsWithType( wrapper, Popover ) ).toHaveLength( 1 );
expect( TestUtils.scryRenderedDOMComponentsWithClass( wrapper, 'components-popover' ) ).toHaveLength( 1 );
} );
} );
} );
6 changes: 3 additions & 3 deletions packages/components/src/dropdown/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import TestUtils from 'react-dom/test-utils';
* Internal dependencies
*/
import Dropdown from '../';
import Popover from '../../popover';

describe( 'Dropdown', () => {
const expectPopoverVisible = ( wrapper, visible ) => {
expect(
TestUtils.scryRenderedComponentsWithType( wrapper, Popover ) )
TestUtils.scryRenderedDOMComponentsWithClass( wrapper, 'components-popover' ) )
.toHaveLength( visible ? 1 : 0 );
};
const buttonElement = ( wrapper ) => TestUtils.findRenderedDOMComponentWithTag(
Expand All @@ -31,13 +30,14 @@ describe( 'Dropdown', () => {
buttonElement( wrapper ).getAttribute( 'aria-expanded' )
).toBe( expanded.toString() );
};

const wrapper = TestUtils.renderIntoDocument( <Dropdown
className="container"
contentClassName="content"
renderToggle={ ( { isOpen, onToggle } ) => (
<button aria-expanded={ isOpen } onClick={ onToggle }>Toggleee</button>
) }
renderContent={ () => null }
renderContent={ () => <span>test</span> }
/> );

expectButtonExpanded( wrapper, false );
Expand Down
Loading