Keep cell hover when moving cursor to iframe (#1051)

This commit is contained in:
Jonatan Kłosko 2022-03-15 11:52:21 +01:00 committed by GitHub
parent cd7b211864
commit 580116ea97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 2 deletions

View file

@ -73,7 +73,7 @@ solely client-side operations.
@apply pointer-events-none; @apply pointer-events-none;
} }
[data-element="cell"]:not([data-js-focused]):hover [data-element="cell"]:not([data-js-focused])[data-js-hover]
[data-element="actions"][data-primary] { [data-element="actions"][data-primary] {
@apply opacity-100 pointer-events-auto; @apply opacity-100 pointer-events-auto;
} }
@ -92,7 +92,7 @@ solely client-side operations.
@apply text-gray-900; @apply text-gray-900;
} }
[data-element="cell"]:not([data-js-focused]):hover [data-element="cell"]:not([data-js-focused])[data-js-hover]
[data-element="cell-focus-indicator"] { [data-element="cell-focus-indicator"] {
@apply bg-blue-200; @apply bg-blue-200;
} }

View file

@ -63,6 +63,16 @@ const Cell = {
handleCellEditorRemoved(this, tag); handleCellEditorRemoved(this, tag);
}); });
// We manually track hover to correctly handle absolute iframe
this.el.addEventListener("mouseenter", (event) => {
this.el.setAttribute("data-js-hover", "true");
});
this.el.addEventListener("mouseleave", (event) => {
this.el.removeAttribute("data-js-hover");
});
this._unsubscribeFromNavigationEvents = globalPubSub.subscribe( this._unsubscribeFromNavigationEvents = globalPubSub.subscribe(
"navigation", "navigation",
(event) => { (event) => {

View file

@ -80,6 +80,22 @@ const JSView = {
this.disconnectObservers = bindIframeSize(iframe, iframePlaceholder); this.disconnectObservers = bindIframeSize(iframe, iframePlaceholder);
// Emulate mouse enter and leave on the placeholder. Note that we
// intentionally use bubbling to notify all parents that may have
// listeners on themselves
iframe.addEventListener("mouseenter", (event) => {
iframePlaceholder.dispatchEvent(
new MouseEvent("mouseenter", { bubbles: true })
);
});
iframe.addEventListener("mouseleave", (event) => {
iframePlaceholder.dispatchEvent(
new MouseEvent("mouseleave", { bubbles: true })
);
});
// Register message chandler to communicate with the iframe // Register message chandler to communicate with the iframe
function postMessage(message) { function postMessage(message) {