Skip to content

Commit

Permalink
Popover: Making the expandOnMobile prop opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Nov 9, 2017
1 parent 67da53d commit ac0112f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
8 changes: 8 additions & 0 deletions components/dropdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ A callback invoked to render the content of the dropdown menu. Its first argumen

- Type: `Function`
- Required: Yes

## expandOnMobile

Opt-in prop to show popovers fullscreen on mobile, pass `false` in this prop to avoid this behavior.

- Type: `Boolean`
- Required: No
- Default: `false`
10 changes: 9 additions & 1 deletion components/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ class Dropdown extends Component {

render() {
const { isOpen } = this.state;
const { renderContent, renderToggle, position = 'bottom', className, contentClassName } = this.props;
const {
renderContent,
renderToggle,
position = 'bottom',
className,
contentClassName,
expandOnMobile,
} = this.props;
const args = { isOpen, onToggle: this.toggle, onClose: this.close };
return (
<div className={ className } ref={ this.bindContainer }>
Expand All @@ -72,6 +79,7 @@ class Dropdown extends Component {
position={ position }
onClose={ this.close }
onClickOutside={ this.clickOutside }
expandOnMobile={ expandOnMobile }
>
<FocusManaged>
{ renderContent( args ) }
Expand Down
5 changes: 2 additions & 3 deletions components/popover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ A callback invoked when the user clicks outside the opened popover, passing the
- Type: `Function`
- Required: No


## expandOnMobile

Popovers automatically shows up fullscreen on mobile, pass `false` in this prop to avoid this behavior.
Opt-in prop to show popovers fullscreen on mobile, pass `false` in this prop to avoid this behavior.

- Type: `Boolean`
- Required: No
- Default: `true`
- Default: `false`
2 changes: 1 addition & 1 deletion components/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Popover extends Component {
}

setOffset() {
const { getAnchorRect = this.getAnchorRect, expandOnMobile = true } = this.props;
const { getAnchorRect = this.getAnchorRect, expandOnMobile = false } = this.props;
const { popover } = this.nodes;

if ( isMobile() && expandOnMobile ) {
Expand Down
4 changes: 2 additions & 2 deletions components/popover/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe( 'Popover', () => {
let wrapper, mocks;
beforeEach( () => {
wrapper = shallow(
<Popover expandOnMobile={ false } />,
<Popover />,
{ lifecycleExperimental: true }
);

Expand Down Expand Up @@ -206,7 +206,7 @@ describe( 'Popover', () => {
} );

function getInstanceWithParentNode() {
const instance = new Popover( { expandOnMobile: false } );
const instance = new Popover( {} );

instance.nodes.anchor = {
parentNode: {
Expand Down
1 change: 0 additions & 1 deletion components/tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ class Tooltip extends Component {
position={ position }
className="components-tooltip"
aria-hidden="true"
expandOnMobile={ false }
>
{ text }
</Popover>,
Expand Down
1 change: 1 addition & 0 deletions editor/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Inserter extends Component {
className="editor-inserter"
position={ position }
onToggle={ this.onToggle }
expandOnMobile
renderToggle={ ( { onToggle, isOpen } ) => (
<IconButton
icon="insert"
Expand Down

0 comments on commit ac0112f

Please sign in to comment.