-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Overlay] better lifecycle props for all overlay components #2581
Changes from all commits
bff8489
7966baf
920ec84
2082975
e7abc1d
67bca7b
be13a7e
09a6c59
26b2ecc
9b9a0ec
4605ede
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,31 +134,11 @@ export interface IPopoverProps extends IOverlayableProps, IProps { | |
*/ | ||
popoverClassName?: string; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a major API deprecation. What is the upgrade path for existing code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: this interface inherits the new lifecycle interface, so this will just be a rename. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
/** | ||
* Callback invoked after the popover closes and has been removed from the DOM. | ||
*/ | ||
popoverDidClose?: () => void; | ||
|
||
/** | ||
* Callback invoked when the popover opens after it is added to the DOM. | ||
*/ | ||
popoverDidOpen?: () => void; | ||
|
||
/** | ||
* Ref supplied to the `Classes.POPOVER` element. | ||
*/ | ||
popoverRef?: (ref: HTMLDivElement | null) => void; | ||
|
||
/** | ||
* Callback invoked when a popover begins to close. | ||
*/ | ||
popoverWillClose?: () => void; | ||
|
||
/** | ||
* Callback invoked before the popover opens. | ||
*/ | ||
popoverWillOpen?: () => void; | ||
|
||
/** | ||
* Space-delimited string of class names applied to the | ||
* portal that holds the popover if `usePortal={true}`. | ||
|
@@ -248,8 +228,6 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState> | |
/** DOM element that contains the target. */ | ||
public targetElement: HTMLElement; | ||
|
||
// a flag that is set to true while we are waiting for the underlying Portal to complete rendering | ||
private isContentMounting = false; | ||
private cancelOpenTimeout: () => void; | ||
|
||
// a flag that lets us detect mouse movement between the target and popover, | ||
|
@@ -277,7 +255,7 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState> | |
} | ||
|
||
public render() { | ||
const { className, disabled, hasBackdrop, targetClassName, targetElementTag } = this.props; | ||
const { className, disabled, targetClassName, targetElementTag } = this.props; | ||
const { isOpen } = this.state; | ||
const isHoverInteractionKind = this.isHoverInteractionKind(); | ||
|
||
|
@@ -333,15 +311,17 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState> | |
canEscapeKeyClose={this.props.canEscapeKeyClose} | ||
canOutsideClickClose={this.props.interactionKind === PopoverInteractionKind.CLICK} | ||
className={this.props.portalClassName} | ||
didClose={this.props.popoverDidClose} | ||
didOpen={this.handleContentMount} | ||
enforceFocus={this.props.enforceFocus} | ||
hasBackdrop={hasBackdrop} | ||
usePortal={this.props.usePortal} | ||
hasBackdrop={this.props.hasBackdrop} | ||
isOpen={isOpen && !isContentEmpty} | ||
onClose={this.handleOverlayClose} | ||
onClosed={this.props.onClosed} | ||
onClosing={this.props.onClosing} | ||
onOpened={this.props.onOpened} | ||
onOpening={this.props.onOpening} | ||
transitionDuration={this.props.transitionDuration} | ||
transitionName={Classes.POPOVER} | ||
usePortal={this.props.usePortal} | ||
> | ||
{this.renderPopper(children.content)} | ||
</Overlay> | ||
|
@@ -369,15 +349,6 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState> | |
} | ||
} | ||
|
||
public componentWillUpdate(_: IPopoverProps, nextState: IPopoverState) { | ||
if (!this.state.isOpen && nextState.isOpen) { | ||
this.isContentMounting = true; | ||
Utils.safeInvoke(this.props.popoverWillOpen); | ||
} else if (this.state.isOpen && !nextState.isOpen) { | ||
Utils.safeInvoke(this.props.popoverWillClose); | ||
} | ||
} | ||
|
||
public componentDidUpdate() { | ||
this.updateDarkParent(); | ||
} | ||
|
@@ -504,13 +475,6 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState> | |
} | ||
} | ||
|
||
private handleContentMount = () => { | ||
if (this.isContentMounting) { | ||
Utils.safeInvoke(this.props.popoverDidOpen); | ||
this.isContentMounting = false; | ||
} | ||
}; | ||
|
||
private handleTargetFocus = (e: React.FocusEvent<HTMLElement>) => { | ||
if (this.props.openOnTargetFocus && this.isHoverInteractionKind()) { | ||
if (e.relatedTarget == null && !this.lostFocusOnSamePage) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a pretty major change where users could possible pass props to the popover this way, now they can't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this component is not even exported, so it think we're safe here. users use either a decorator
@ContextMenuTarget
or a static methodContextMenu.show()
(which looks like this component but isn't).