Skip to content

Commit 7628617

Browse files
committed
Improve behavior of claims tooltips, especially in Firefox.
1 parent e38c9c2 commit 7628617

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/editor/claims-tooltip.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import tippy from 'tippy.js';
1212
const timeClaims = ['exp', 'nbf', 'iat', 'auth_time', 'updated_at'];
1313

1414
function hideTooltip() {
15-
decodedElement._tippy.hide();
15+
decodedElement._tippy.popper.style.opacity = 0;
1616
}
1717

1818
function showTooltip(text) {
19-
decodedElement.title = text;
20-
decodedElement._tippy.show();
19+
decodedElement._tippy.popper.querySelector('.tippy-content')
20+
.textContent = text;
21+
decodedElement._tippy.popperInstance.update();
22+
decodedElement._tippy.popper.style.opacity = 1;
2123
}
2224

2325
function getTimeText(timeStr) {
@@ -28,6 +30,7 @@ function tooltipHandler(event) {
2830
const editor = event.currentTarget.querySelector('.CodeMirror').CodeMirror;
2931

3032
if(!editor) {
33+
hideTooltip();
3134
return;
3235
}
3336

@@ -64,17 +67,21 @@ function tooltipHandler(event) {
6467
showTooltip(claimText);
6568
}
6669

67-
export function setupClaimsTooltip() {
68-
tippy(decodedElement, {
70+
export function setupClaimsTooltip() {
71+
tippy(decodedElement, {
6972
placement: 'left',
7073
arrow: true,
7174
followCursor: true,
7275
performance: true,
7376
size: 'large',
7477
dynamicTitle: true,
7578
arrowTransform: 'scale(0.75)',
76-
distance: 20
77-
});
79+
distance: 20,
80+
sticky: true,
81+
updateDuration: 100
82+
});
83+
84+
decodedElement._tippy.popper.style.opacity = 0;
7885

7986
payloadElement.addEventListener('mousemove', tooltipHandler);
8087
headerElement.addEventListener('mousemove', tooltipHandler);

0 commit comments

Comments
 (0)