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

fix(color-picker, popover, shell-panel, slider, tooltip): Register events on the window instead of the document #8247

Merged
merged 1 commit into from
Nov 22, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ export class ColorPicker

const { offsetX, offsetY } = event;

document.addEventListener("pointermove", this.globalPointerMoveHandler);
document.addEventListener("pointerup", this.globalPointerUpHandler, { once: true });
window.addEventListener("pointermove", this.globalPointerMoveHandler);
window.addEventListener("pointerup", this.globalPointerUpHandler, { once: true });

this.activeCanvasInfo = {
context: this.colorFieldRenderingContext,
Expand All @@ -547,8 +547,8 @@ export class ColorPicker

const { offsetX } = event;

document.addEventListener("pointermove", this.globalPointerMoveHandler);
document.addEventListener("pointerup", this.globalPointerUpHandler, { once: true });
window.addEventListener("pointermove", this.globalPointerMoveHandler);
window.addEventListener("pointerup", this.globalPointerUpHandler, { once: true });

this.activeCanvasInfo = {
context: this.hueSliderRenderingContext,
Expand All @@ -565,8 +565,8 @@ export class ColorPicker

const { offsetX } = event;

document.addEventListener("pointermove", this.globalPointerMoveHandler);
document.addEventListener("pointerup", this.globalPointerUpHandler, { once: true });
window.addEventListener("pointermove", this.globalPointerMoveHandler);
window.addEventListener("pointerup", this.globalPointerUpHandler, { once: true });

this.activeCanvasInfo = {
context: this.opacitySliderRenderingContext,
Expand Down Expand Up @@ -695,8 +695,8 @@ export class ColorPicker
}

disconnectedCallback(): void {
document.removeEventListener("pointermove", this.globalPointerMoveHandler);
document.removeEventListener("pointerup", this.globalPointerUpHandler);
window.removeEventListener("pointermove", this.globalPointerMoveHandler);
window.removeEventListener("pointerup", this.globalPointerUpHandler);
disconnectInteractive(this);
disconnectLocalized(this);
disconnectMessages(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export default class PopoverManager {
};

private addListeners(): void {
document.addEventListener("pointerdown", this.clickHandler, { capture: true });
document.addEventListener("keydown", this.keyHandler, { capture: true });
window.addEventListener("pointerdown", this.clickHandler, { capture: true });
window.addEventListener("keydown", this.keyHandler, { capture: true });
}

private removeListeners(): void {
document.removeEventListener("pointerdown", this.clickHandler, { capture: true });
document.removeEventListener("keydown", this.keyHandler, { capture: true });
window.removeEventListener("pointerdown", this.clickHandler, { capture: true });
window.removeEventListener("keydown", this.keyHandler, { capture: true });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ export class ShellPanel implements ConditionalSlotComponent, LocalizedComponent,
}

event.preventDefault();
document.removeEventListener("pointerup", this.separatorPointerUp);
document.removeEventListener("pointermove", this.separatorPointerMove);
window.removeEventListener("pointerup", this.separatorPointerUp);
window.removeEventListener("pointermove", this.separatorPointerMove);
};

setInitialContentHeight = (): void => {
Expand Down Expand Up @@ -608,8 +608,8 @@ export class ShellPanel implements ConditionalSlotComponent, LocalizedComponent,
this.initialClientX = event.clientX;
}

document.addEventListener("pointerup", this.separatorPointerUp);
document.addEventListener("pointermove", this.separatorPointerMove);
window.addEventListener("pointerup", this.separatorPointerUp);
window.addEventListener("pointermove", this.separatorPointerMove);
};

connectSeparator = (separatorEl: HTMLDivElement): void => {
Expand Down
12 changes: 6 additions & 6 deletions packages/calcite-components/src/components/slider/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1068,9 +1068,9 @@ export class Slider
this.dragProp = prop;
this.lastDragProp = this.dragProp;
this.activeProp = prop;
document.addEventListener("pointermove", this.dragUpdate);
document.addEventListener("pointerup", this.pointerUpDragEnd);
document.addEventListener("pointercancel", this.dragEnd);
window.addEventListener("pointermove", this.dragUpdate);
window.addEventListener("pointerup", this.pointerUpDragEnd);
window.addEventListener("pointercancel", this.dragEnd);
}

private focusActiveHandle(valueX: number): void {
Expand Down Expand Up @@ -1157,9 +1157,9 @@ export class Slider
};

private removeDragListeners() {
document.removeEventListener("pointermove", this.dragUpdate);
document.removeEventListener("pointerup", this.pointerUpDragEnd);
document.removeEventListener("pointercancel", this.dragEnd);
window.removeEventListener("pointermove", this.dragUpdate);
window.removeEventListener("pointerup", this.pointerUpDragEnd);
window.removeEventListener("pointercancel", this.dragEnd);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,19 @@ export default class TooltipManager {
}

private addListeners(): void {
document.addEventListener("keydown", this.keyDownHandler, { capture: true });
document.addEventListener("pointermove", this.pointerMoveHandler, { capture: true });
document.addEventListener("pointerdown", this.pointerDownHandler, { capture: true });
document.addEventListener("focusin", this.focusInHandler, { capture: true });
document.addEventListener("focusout", this.focusOutHandler, { capture: true });
window.addEventListener("keydown", this.keyDownHandler, { capture: true });
window.addEventListener("pointermove", this.pointerMoveHandler, { capture: true });
window.addEventListener("pointerdown", this.pointerDownHandler, { capture: true });
window.addEventListener("focusin", this.focusInHandler, { capture: true });
window.addEventListener("focusout", this.focusOutHandler, { capture: true });
}

private removeListeners(): void {
document.removeEventListener("keydown", this.keyDownHandler, { capture: true });
document.removeEventListener("pointermove", this.pointerMoveHandler, { capture: true });
document.removeEventListener("pointerdown", this.pointerDownHandler, { capture: true });
document.removeEventListener("focusin", this.focusInHandler, { capture: true });
document.removeEventListener("focusout", this.focusOutHandler, { capture: true });
window.removeEventListener("keydown", this.keyDownHandler, { capture: true });
window.removeEventListener("pointermove", this.pointerMoveHandler, { capture: true });
window.removeEventListener("pointerdown", this.pointerDownHandler, { capture: true });
window.removeEventListener("focusin", this.focusInHandler, { capture: true });
window.removeEventListener("focusout", this.focusOutHandler, { capture: true });
}

private clearHoverOpenTimeout(): void {
Expand Down
Loading