Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a00d359

Browse files
Fix left positioned tooltips being wrong and offset by fixed value (#7551)
Previously, the `left` positioning seemed to only work with icons which are all about the same size so the arbitrary offset worked. Now we actually position off to the left of the element and we have equal `margin-left` and `margin-right` to determine the offset. Spawned from #7339 (comment)
1 parent b50060b commit a00d359

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

res/css/views/elements/_Tooltip.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ limitations under the License.
6060
font-weight: 500;
6161
max-width: 200px;
6262
word-break: break-word;
63-
margin-right: 50px;
63+
margin-left: 6px;
64+
margin-right: 6px;
6465

6566
background-color: #21262C; // Same on both themes
6667
color: $accent-fg-color;

res/css/views/rooms/_EventTile.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ $left-gutter: 64px;
2020
.mx_EventTile {
2121
.mx_EventTile_receiptSent,
2222
.mx_EventTile_receiptSending {
23+
// Give it some dimensions so the tooltip can position properly
24+
display: inline-block;
25+
width: 14px;
26+
height: 14px;
2327
// We don't use `position: relative` on the element because then it won't line
2428
// up with the other read receipts
2529

src/components/views/elements/Tooltip.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ export default class Tooltip extends React.Component<ITooltipProps> {
117117
);
118118
const baseTop = (parentBox.top - 2 + this.props.yOffset) + window.pageYOffset;
119119
const top = baseTop + offset;
120-
const right = width - parentBox.right - window.pageXOffset - 16;
121-
const left = parentBox.right + window.pageXOffset + 6;
120+
const right = width - parentBox.left - window.pageXOffset;
121+
const left = parentBox.right + window.pageXOffset;
122122
const horizontalCenter = (
123123
parentBox.left - window.pageXOffset + (parentWidth / 2)
124124
);

src/components/views/rooms/EventTile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,7 @@ class SentReceipt extends React.PureComponent<ISentReceiptProps, ISentReceiptSta
17281728
}
17291729
// The yOffset is somewhat arbitrary - it just brings the tooltip down to be more associated
17301730
// with the read receipt.
1731-
tooltip = <Tooltip className="mx_EventTile_readAvatars_receiptTooltip" label={label} yOffset={20} />;
1731+
tooltip = <Tooltip className="mx_EventTile_readAvatars_receiptTooltip" label={label} yOffset={3} />;
17321732
}
17331733

17341734
return (

test/components/views/elements/__snapshots__/TooltipTarget-test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`<TooltipTarget /> displays tooltip on mouseover 1`] = `
44
<div
55
class="mx_Tooltip test tooltipClassName mx_Tooltip_visible"
6-
style="right: 1008px; top: -26px; display: block;"
6+
style="right: 1024px; top: -26px; display: block;"
77
>
88
<div
99
class="mx_Tooltip_chevron"

0 commit comments

Comments
 (0)