Skip to content
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

Allow context menu out of cell #2329

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ export class KupInputPanel {
});
}}
onContextMenu={(e: MouseEvent) => {
e.preventDefault();
if (this.#findTraversedFCell(e) != null) {
e.preventDefault();
}
}}
>
<div class="input-panel__typography">
Expand Down Expand Up @@ -1804,11 +1806,17 @@ export class KupInputPanel {
});
}

#findTraversedFCell(e: MouseEvent): HTMLElement | null {
const path = this.#kupManager.getEventPath(e.target, this.rootElement);
const fcell = path.find((p) => p.classList?.contains('f-cell'));
return fcell;
}

#getEventDetails(
path: HTMLElement[],
originalEvent: PointerEvent
): KupInputPanelEventHandlerDetails {
const fcell = path.find((p) => p.classList?.contains('f-cell'));
const fcell = this.#findTraversedFCell(originalEvent);

if (fcell == null) {
return;
}
Expand All @@ -1832,21 +1840,13 @@ export class KupInputPanel {
};
}

#contextMenuHandler(e: PointerEvent): KupInputPanelEventHandlerDetails {
const eventPath = this.#kupManager.getEventPath(
e.target,
this.rootElement
);

return this.#getEventDetails(eventPath, e);
}

#didLoadInteractables() {
// this could seems like a duplication because this.#kupManager.interact.on already does it but removing this causes an error on righ-clicking a TBL cell with tooltip when set as shape of an input panel cell
this.#kupManager.interact.managedElements.add(this.#formRef);

const tapCb = (e: PointerEvent) => {
if (e.button == 2) {
const details = this.#contextMenuHandler(e);
const details = this.#getEventDetails(e);

if (details) {
this.kupDataTableContextMenu.emit({
Expand Down
Loading