Skip to content

Allow nubbin to change position when popover flips #1304

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

Closed
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
11 changes: 10 additions & 1 deletion components/popover/popover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ const Popover = createReactClass({
getInitialState () {
return {
isOpen: false,
nubbinPositionClass: getNubbinClassName(this.props.align)
};
},

Expand Down Expand Up @@ -422,13 +423,21 @@ const Popover = createReactClass({
}
},

handleNubbinPositionUpdate (placement) {
const nubbinClassName = getNubbinClassName(placement);
this.setState({
nubbinPositionClass: nubbinClassName
});
},

renderDialog (isOpen, outsideClickIgnoreClass) {
const props = this.props;
const offset = props.offset;
const style = this.props.style || {};

return isOpen ? (
<Dialog
handleNubbinPositionUpdate={this.handleNubbinPositionUpdate}
align={props.align}
contentsClassName={classNames(
this.props.contentsClassName,
Expand Down Expand Up @@ -463,7 +472,7 @@ const Popover = createReactClass({
aria-describedby={`${this.getId()}-dialog-body`}
className={classNames(
'slds-popover',
getNubbinClassName(props.align),
this.state.nubbinPositionClass,
props.className
)}
id={`${this.getId()}-popover`}
Expand Down
8 changes: 7 additions & 1 deletion components/utilities/dialog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ const Dialog = createReactClass({
return { ...popperData.style, left, top, position };
},

onUpdate (data) {
const placement = data.placement;
this.props.handleNubbinPositionUpdate(placement);
},

// Render
setDialogContent (component) {
this.dialogContent = component;
Expand Down Expand Up @@ -313,7 +318,6 @@ const Dialog = createReactClass({
/**
* Popper API and helper functions
*/

createPopper () {
const reference = this.props.onRequestTargetElement(); // eslint-disable-line react/no-find-dom-node
const popper = this.dialogContent;
Expand Down Expand Up @@ -352,6 +356,7 @@ const Dialog = createReactClass({
console.error('Popper node not found!', popper); // eslint-disable-line no-console
}
this.popper = new Popper(reference, popper, {
onUpdate: this.onUpdate,
placement,
eventsEnabled,
modifiers,
Expand Down Expand Up @@ -429,6 +434,7 @@ const Dialog = createReactClass({

Dialog.contextTypes = {
iconPath: PropTypes.string,
handleNubbinPositionUpdate: PropTypes.func,
};

export default Dialog;
Loading