Improve tooltips behavior#9668
Conversation
| observe('.rgh-tooltip', tooltip => { | ||
| tooltip.style.display = ''; | ||
| tooltipContainer!.append(tooltip); | ||
| }); |
There was a problem hiding this comment.
Reason to #9482 (comment) seems to be that tooltip need to be attached to the DOM after the target element. Hence this dance. I also tried custom elements but that need to be in MAIN world.
|
😬 Code is not the prettiest but should be most correct |
|
So what you're saying is that it works if you append it near the element, and then move it away after the custom element activates? If so, you can just use a timeout and skip the observer, e.g. |
|
"After" in time, not in location. Timeout does nothing since at this time neither the tooltip nor the target is attached to DOM. |
|
What you said contradicts itself. If "after in time", how can "timeout do nothing"? That's what timeout does. If not 0ms then 100ms will do. I think that in all cases we generate and immediately append the elements, I don't think there's any scenario in which we create the tooltip and append it to the dom at a later time. |
|
Actually according to chat you should be able to append them together to the body to "warm them up" and then remove them. document.body.append(el, tooltip);
el.remove();
tooltip.remove()at this point you can just add tooltip to the ajaxed container and proceed with the regular element insertion. |
|
Sorry, let me rephrase it more clearly. The tooltip works if attached to the DOM at the same time as the target, or after. It does not work it attached if before target (so we can't It may work if we |
|
Oh wait it seems to work. I'm still not sure it works all the time though. |
| const tooltip = createTooltipFor(element, content); | ||
| element.append(tooltip); | ||
|
|
||
| // #9668 |
There was a problem hiding this comment.
Since linkify-code is broken I stopped using this type of comment unless there's a proper comment (and even then). So a full URL is preferred
| margin-left: var(--base-size-6, 0.375rem); | ||
| overflow: visible; | ||
| /* eslint-disable-next-line css/font-family-fallbacks */ | ||
| font-family: inherit; |
There was a problem hiding this comment.
I don't know what's up with this. If Eslint passes with or without this, something must be broken. Restoring...
There was a problem hiding this comment.
npm run fix keeps auto-fixing this one. I added it in since it's kinda related...
There was a problem hiding this comment.
Yeah it's been annoying. Sorry yeah let's remove it again 😅 and then I'll look into why that's the case separately.
There was a problem hiding this comment.
Different plugin, same issue:
I'm seeing the error in my IDE as a warning (it should be an error) but $ eslint doesn't even mention it as a warning. So it's not us
|
Does anything from #9508 need to be undone thanks to this fix? I'm thinking the new p- and m- classes added are no longer needed. If you can clean it up in this PR (without affecting sizing/spacing) that'd be great. |
This reverts commit dfc7039.
|
|
|
#9666 shows this bug on |
There was a problem hiding this comment.
I think the solution is even easier since element is already attached to the document
const tooltip = createTooltipFor(element, content);
element.after(tooltip); // triggers connectedCallback()
appendToPjaxContainer(tooltip);There was a problem hiding this comment.
We don't need element.append(tooltip), I kept it in case there's issue appending tooltip to container - a not so perfect tooltip is better than none
There was a problem hiding this comment.
Oh I get what you meant earlier now
|
Right, I fixed |
| ); | ||
|
|
||
| // Occasionally this button appears before "Reviewers", so let's wait a bit longer | ||
| await delay(300); |
There was a problem hiding this comment.
It turns out that there was one instance in which we waited after generating the element, but this was not necessarily desired behavior.
Fix #9666
Test URLs
Here
Screenshot
Screen.Recording.2026-06-01.at.9.20.58.PM.mov