-
Notifications
You must be signed in to change notification settings - Fork 1.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
[WIP] Fix calculation for center aligned popover #2362
Changes from all commits
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 |
---|---|---|
|
@@ -44,7 +44,6 @@ export interface PositionedOverlayProps { | |
interface State { | ||
measuring: boolean; | ||
activatorRect: Rect; | ||
right?: number; | ||
left: number; | ||
top: number; | ||
height: number; | ||
|
@@ -122,18 +121,12 @@ export class PositionedOverlay extends React.PureComponent< | |
const {top, zIndex, width} = this.state; | ||
const {render, fixed, classNames: propClassNames} = this.props; | ||
|
||
const right = | ||
this.state.right == null || isNaN(this.state.right) | ||
? undefined | ||
: this.state.right; | ||
|
||
const left = | ||
right != null || this.state.left == null || isNaN(this.state.left) | ||
this.state.left == null || isNaN(this.state.left) | ||
? undefined | ||
: this.state.left; | ||
|
||
const style = { | ||
right, | ||
left, | ||
top: top == null || isNaN(top) ? undefined : top, | ||
width: width == null || isNaN(width) ? undefined : width, | ||
|
@@ -238,17 +231,14 @@ export class PositionedOverlay extends React.PureComponent< | |
activatorRect, | ||
overlayRect, | ||
containerRect, | ||
overlayMargins, | ||
preferredAlignment, | ||
); | ||
|
||
this.setState( | ||
{ | ||
measuring: false, | ||
activatorRect: getRectForNode(activator), | ||
right: | ||
preferredAlignment === 'right' ? horizontalPosition : undefined, | ||
left: preferredAlignment === 'right' ? 0 : horizontalPosition, | ||
left: horizontalPosition, | ||
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. Remove the right value and only positioning the popover with the left value. This is how it previously worked. This simplifies the math when the popover overlaps the page. It now doesn't have to calculate a three right values it can just switch to a previously defined left value. |
||
top: lockPosition ? top : verticalPosition.top, | ||
lockPosition: Boolean(fixed), | ||
height: verticalPosition.height || 0, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,6 @@ export function UserMenu({ | |
|
||
return ( | ||
<Menu | ||
preferredAlignment="right" | ||
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 should work with default middle, left or right alignment. If the popover overlaps the right hand side of the page it should use a different left value. |
||
activatorContent={activatorContentMarkup} | ||
open={open} | ||
onOpen={onToggle} | ||
|
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.
I'm not sure why the popover needed margin on the horizontal axis as it is positioned absolutely.