This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 828
Fix left positioned tooltips being wrong and offset by fixed value #7551
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
33407c5
Fix tooltip left position being wrong and offset by fixed value
MadLittleMods c559e90
Remove debug logging
MadLittleMods 6c6e246
Adjust spacing to be more similar to before
MadLittleMods deb1f30
Fix read receipt tooltip not positioning correctly
MadLittleMods 511849b
Update test snapshot
MadLittleMods ffece09
Adjust vertical offset to be centered
MadLittleMods ee6f3f8
Beter vertical center
MadLittleMods dca8d2e
Merge branch 'develop' into madlittlemods/fix-tooltip-positions
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,7 @@ export default class Tooltip extends React.Component<ITooltipProps> { | |
|
||
private updatePosition(style: CSSProperties) { | ||
const parentBox = this.parent.getBoundingClientRect(); | ||
console.log('updatePosition', 'alignment', this.props.alignment, 'parentBox', parentBox); | ||
let offset = 0; | ||
if (parentBox.height > MIN_TOOLTIP_HEIGHT) { | ||
offset = Math.floor((parentBox.height - MIN_TOOLTIP_HEIGHT) / 2); | ||
|
@@ -110,27 +111,30 @@ export default class Tooltip extends React.Component<ITooltipProps> { | |
offset = Math.floor(parentBox.height - MIN_TOOLTIP_HEIGHT); | ||
} | ||
const width = UIStore.instance.windowWidth; | ||
console.log('tooltip width', width) | ||
const parentWidth = ( | ||
this.props.maxParentWidth | ||
? Math.min(parentBox.width, this.props.maxParentWidth) | ||
: parentBox.width | ||
); | ||
const baseTop = (parentBox.top - 2 + this.props.yOffset) + window.pageYOffset; | ||
const top = baseTop + offset; | ||
const right = width - parentBox.right - window.pageXOffset - 16; | ||
const left = parentBox.right + window.pageXOffset + 6; | ||
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. Removing arbitrary offsets |
||
const right = width - parentBox.left - window.pageXOffset; | ||
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. |
||
const left = parentBox.right + window.pageXOffset; | ||
const horizontalCenter = ( | ||
parentBox.left - window.pageXOffset + (parentWidth / 2) | ||
); | ||
switch (this.props.alignment) { | ||
case Alignment.Natural: | ||
if (parentBox.right > width / 2) { | ||
console.log('natural left'); | ||
style.right = right; | ||
style.top = top; | ||
break; | ||
} | ||
// fall through to Right | ||
case Alignment.Right: | ||
console.log('right'); | ||
style.left = left; | ||
style.top = top; | ||
break; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 can't remove the
element-web
reviewer? I don't want to assign for review until ready.Seems to be locked 🤔
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.
not sure why - was this opened as a draft from the start or converted to a draft?
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 think it was created normally. And I see the system note for converting to draft here:
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.
Maybe it's something to do with the code owner but I don't think I did anything to trigger that (edit: maybe not, seems to be the same on other PRs). Usually it assigns
element-web
but I can remove it.