Skip to content
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
10 changes: 10 additions & 0 deletions common/changes/callout-min-page-padding_2017-05-05-20-29.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Callout: Add minPagePadding. Dropdown: Expose calloutProps",
"type": "minor"
}
],
"email": "micahgodbolt@gmail.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export interface ICalloutProps extends React.Props<Callout | CalloutContent> {
*/
bounds?: IRectangle;

/**
* The minimum distance the callout will be away from the edge of the screen.
* @default 8
*/
minPagePadding?: number;

/**
* If true use a point rather than rectangle to position the Callout.
* For example it can be used to position based on a click.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const styles: any = stylesImport;
const BEAK_ORIGIN_POSITION = { top: 0, left: 0 };
const OFF_SCREEN_STYLE = { opacity: 0 };
const BORDER_WIDTH: number = 1;
const SPACE_FROM_EDGE: number = 8;

export interface ICalloutState {
positions?: IPositionInfo;
Expand All @@ -37,6 +36,7 @@ export class CalloutContent extends BaseComponent<ICalloutProps, ICalloutState>
isBeakVisible: true,
beakWidth: 16,
gapSpace: 0,
minPagePadding: 8,
directionalHint: DirectionalHint.bottomAutoEdge
};

Expand Down Expand Up @@ -265,12 +265,12 @@ export class CalloutContent extends BaseComponent<ICalloutProps, ICalloutState>

if (!currentBounds) {
currentBounds = {
top: 0 + SPACE_FROM_EDGE,
left: 0 + SPACE_FROM_EDGE,
right: this._targetWindow.innerWidth - SPACE_FROM_EDGE,
bottom: this._targetWindow.innerHeight - SPACE_FROM_EDGE,
width: this._targetWindow.innerWidth - SPACE_FROM_EDGE * 2,
height: this._targetWindow.innerHeight - SPACE_FROM_EDGE * 2
top: 0 + this.props.minPagePadding,
left: 0 + this.props.minPagePadding,
right: this._targetWindow.innerWidth - this.props.minPagePadding,
bottom: this._targetWindow.innerHeight - this.props.minPagePadding,
width: this._targetWindow.innerWidth - this.props.minPagePadding * 2,
height: this._targetWindow.innerHeight - this.props.minPagePadding * 2
};
}
this._bounds = currentBounds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ContextualMenu } from './ContextualMenu';
import { DirectionalHint } from '../../common/DirectionalHint';
import { FocusZoneDirection } from '../../FocusZone';
import { IIconProps } from '../Icon/Icon.Props';
import { ICalloutProps } from '../../Callout';
import {
IPoint,
IRectangle
Expand Down Expand Up @@ -164,6 +165,11 @@ export interface IContextualMenuProps extends React.Props<ContextualMenu> {
*/
onMenuOpened?: (contextualMenu?: IContextualMenuProps) => void;

/**
* Pass in custom callout props
*/
calloutProps?: ICalloutProps;

}

export interface IContextualMenuItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext
target,
bounds,
directionalHintFixed,
shouldFocusOnMount } = this.props;
shouldFocusOnMount,
calloutProps } = this.props;

let { submenuProps } = this.state;

Expand All @@ -194,6 +195,7 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext
if (items && items.length > 0) {
return (
<Callout
{...calloutProps}
target={ target }
targetElement={ targetElement }
targetPoint={ targetPoint }
Expand All @@ -217,7 +219,7 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext
ariaLabelledBy={ labelElementId }
ref={ (focusZone) => this._focusZone = focusZone }
role='menu'
aria-label={ ariaLabel }
aria-label={ ariaLabel }
isCircularNavigation={ true }
>
<ul
Expand Down