From 817bad768cb334b0defd53aac7aa137b96aa483d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 09:44:35 -0400 Subject: [PATCH 1/3] chore(deps): bump @types/chai from 4.3.4 to 4.3.5 (#6097) --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 96f8bebbfd..4793451a17 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "verify": "npm-run-all -s compile dist:libs dist:apps -p test lint format-check" }, "dependencies": { - "@types/chai": "~4.3.4", + "@types/chai": "~4.3.5", "@types/enzyme": "~3.10.12", "@types/enzyme-adapter-react-16": "~1.0.6", "@types/mocha": "~10.0.1", diff --git a/yarn.lock b/yarn.lock index a99d22a318..f0e3edecaa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1462,10 +1462,10 @@ resolved "https://registry.yarnpkg.com/@types/btoa-lite/-/btoa-lite-1.0.0.tgz#e190a5a548e0b348adb0df9ac7fa5f1151c7cca4" integrity sha512-wJsiX1tosQ+J5+bY5LrSahHxr2wT+uME5UDwdN1kg4frt40euqA+wzECkmq4t5QbveHiJepfdThgQrPw6KiSlg== -"@types/chai@~4.3.4": - version "4.3.4" - resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.4.tgz#e913e8175db8307d78b4e8fa690408ba6b65dee4" - integrity sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw== +"@types/chai@~4.3.5": + version "4.3.5" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.5.tgz#ae69bcbb1bebb68c4ac0b11e9d8ed04526b3562b" + integrity sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng== "@types/cheerio@*": version "0.22.23" From 8cff95f3ca4e5b697700bf5cc057062f191774a6 Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Thu, 4 May 2023 11:42:54 -0400 Subject: [PATCH 2/3] Fix Nx task dependencies for test/dev tasks (#6123) --- nx.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nx.json b/nx.json index 9c4fafe049..6b3ea36e83 100644 --- a/nx.json +++ b/nx.json @@ -40,7 +40,7 @@ "outputs": ["{projectRoot}/lib/css"] }, "dev": { - "dependsOn": ["^dev"] + "dependsOn": ["^compile"] }, "compile:cjs": { "dependsOn": ["^compile:cjs"], @@ -54,11 +54,14 @@ "dependsOn": ["^dist:bundle"], "outputs": ["{projectRoot}/dist"] }, + "test": { + "dependsOn": ["^compile"] + }, "test:karma": { - "dependsOn": ["^test:karma"] + "dependsOn": [] }, "test:karma:debug": { - "dependsOn": ["^test:karma:debug"] + "dependsOn": [] }, "bundle": { "dependsOn": ["^bundle"], From 9c1384a686bcae02ae3a84154cf5750ec3c22bfd Mon Sep 17 00:00:00 2001 From: Dylan Cooke <38812057+dylanrcooke@users.noreply.github.com> Date: Thu, 4 May 2023 13:47:13 -0400 Subject: [PATCH 3/3] [core] feat(Overlay, Portal): allow portal to stop event propagation (#6093) Co-authored-by: Dylan Cooke Co-authored-by: Adi Dahiya --- .../core/src/components/overlay/overlay.tsx | 15 ++++++++++- .../core/src/components/portal/portal.tsx | 27 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/core/src/components/overlay/overlay.tsx b/packages/core/src/components/overlay/overlay.tsx index 97568ac81b..838283fb08 100644 --- a/packages/core/src/components/overlay/overlay.tsx +++ b/packages/core/src/components/overlay/overlay.tsx @@ -109,6 +109,15 @@ export interface IOverlayableProps extends IOverlayLifecycleProps { */ portalContainer?: HTMLElement; + /** + * A list of DOM events which should be stopped from propagating through the Portal. + * This prop is ignored if `usePortal` is `false`. + * + * @see https://legacy.reactjs.org/docs/portals.html#event-bubbling-through-portals + * @see https://github.com/palantir/blueprint/issues/6124 + */ + portalStopPropagationEvents?: Array; + /** * A callback that is invoked when user interaction causes the overlay to close, such as * clicking on the overlay or pressing the `esc` key (if enabled). @@ -318,7 +327,11 @@ export class Overlay extends AbstractPureComponent2 ); if (usePortal) { return ( - + {transitionGroup} ); diff --git a/packages/core/src/components/portal/portal.tsx b/packages/core/src/components/portal/portal.tsx index 1d6880ef1c..ed11cc8c97 100644 --- a/packages/core/src/components/portal/portal.tsx +++ b/packages/core/src/components/portal/portal.tsx @@ -40,6 +40,14 @@ export interface IPortalProps extends Props { * @default document.body */ container?: HTMLElement; + + /** + * A list of DOM events which should be stopped from propagating through this portal element. + * + * @see https://legacy.reactjs.org/docs/portals.html#event-bubbling-through-portals + * @see https://github.com/palantir/blueprint/issues/6124 + */ + stopPropagationEvents?: Array; } export interface IPortalState { @@ -103,6 +111,7 @@ export class Portal extends React.Component { } this.portalElement = this.createContainerElement(); this.props.container.appendChild(this.portalElement); + this.addStopPropagationListeners(this.props.stopPropagationEvents); /* eslint-disable-next-line react/no-did-mount-set-state */ this.setState({ hasMounted: true }, this.props.onChildrenMount); } @@ -113,9 +122,15 @@ export class Portal extends React.Component { maybeRemoveClass(this.portalElement.classList, prevProps.className); maybeAddClass(this.portalElement.classList, this.props.className); } + + if (this.portalElement != null && prevProps.stopPropagationEvents !== this.props.stopPropagationEvents) { + this.removeStopPropagationListeners(prevProps.stopPropagationEvents); + this.addStopPropagationListeners(this.props.stopPropagationEvents); + } } public componentWillUnmount() { + this.removeStopPropagationListeners(this.props.stopPropagationEvents); this.portalElement?.remove(); } @@ -128,6 +143,14 @@ export class Portal extends React.Component { } return container; } + + private addStopPropagationListeners(eventNames?: Array) { + eventNames?.forEach(event => this.portalElement?.addEventListener(event, handleStopProgation)); + } + + private removeStopPropagationListeners(events?: Array) { + events?.forEach(event => this.portalElement?.removeEventListener(event, handleStopProgation)); + } } function maybeRemoveClass(classList: DOMTokenList, className?: string) { @@ -141,3 +164,7 @@ function maybeAddClass(classList: DOMTokenList, className?: string) { classList.add(...className.split(" ")); } } + +function handleStopProgation(e: Event) { + e.stopPropagation(); +}