Skip to content

feat(hover-service) make hover-service use platform showPopover() #15452

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/core/src/browser/hover-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class HoverService {
this._hoverHost = document.createElement('div');
this._hoverHost.classList.add(HoverService.hostClassName);
this._hoverHost.style.position = 'absolute';
this._hoverHost.setAttribute('popover', 'hint');
}
return this._hoverHost;
}
Expand Down Expand Up @@ -138,6 +139,9 @@ export class HoverService {
host.style.left = '0px';
host.style.top = '0px';
document.body.append(host);
if (!host.matches(':popover-open')) {
host.showPopover();
}

if (request.visualPreview) {
// If just a string is being rendered use the size of the outer box
Expand Down Expand Up @@ -219,6 +223,9 @@ export class HoverService {
}

protected unRenderHover(): void {
if (this.hoverHost.matches(':popover-open')) {
this.hoverHost.hidePopover();
}
this.hoverHost.remove();
this.hoverHost.replaceChildren();
}
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/browser/style/hover-service.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
border: 1px solid var(--theia-editorHoverWidget-border);
padding: var(--theia-ui-padding);
max-width: var(--theia-hover-max-width);
z-index: 1000;
}

/* user agent style-sheet has overflow:hidden, so pointer is not visible but scroll is */
.theia-hover[popover] {
inset: unset;
overflow: visible;
}

.theia-hover .hover-row:not(:first-child):not(:empty) {
Expand Down
Loading