-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] fix(ContextMenuPopover): clean up document handlers on close (#…
- Loading branch information
Showing
15 changed files
with
200 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type * as React from "react"; | ||
|
||
/** Identical to `import("react-dom").Container`, copied here to avoid an unncessary type dependency. */ | ||
type Container = Element | Document | DocumentFragment; | ||
|
||
/** | ||
* Generic options interface for Blueprint APIs which imperatively mount a React component to the | ||
* DOM using `"react-dom"`: `OverlayToaster.create`, `showContextMenu`, etc. | ||
* | ||
* The `domRenderer` currently defaults to React 16's `ReactDOM.render()`; a future version of Blueprint | ||
* will default to using React 18's `createRoot()` instead, but it's possible to configure this | ||
* function to use the newer API by overriding the default. | ||
*/ | ||
export interface DOMMountOptions<P> { | ||
/** | ||
* A new DOM element will be created and appended to this container. | ||
* | ||
* @default document.body | ||
*/ | ||
container?: HTMLElement; | ||
|
||
/** | ||
* A function to render the React component onto a newly created DOM element. | ||
* | ||
* @default ReactDOM.render | ||
*/ | ||
domRenderer?: ( | ||
element: React.ReactElement<P>, | ||
container: Container | null, | ||
) => React.Component<P, any> | Element | void; | ||
|
||
/** | ||
* A function to unmount the React component from its DOM element. | ||
* | ||
* @default ReactDOM.unmountComponentAtNode | ||
*/ | ||
domUnmounter?: (container: Element | DocumentFragment) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { OverlayProps } from "../overlay/overlayProps"; | ||
|
||
/** | ||
* Public instance properties & methods for an overlay in the current overlay stack. | ||
*/ | ||
export interface OverlayInstance { | ||
/** | ||
* Bring document focus inside this overlay element. | ||
* This should be defined if `props.enforceFocus={true}` or `props.autoFocus={true}`. | ||
*/ | ||
bringFocusInsideOverlay?: () => void; | ||
|
||
/** Reference to the overlay container element which may or may not be in a Portal. */ | ||
containerElement: React.RefObject<HTMLDivElement>; | ||
|
||
/** | ||
* Document "focus" event handler which needs to be attached & detached appropriately. | ||
* This should be defined if `props.enforceFocus={true}`. | ||
*/ | ||
handleDocumentFocus?: (e: FocusEvent) => void; | ||
|
||
/** | ||
* Document "mousedown" event handler which needs to be attached & detached appropriately. | ||
* This should be defined if `props.canOutsideClickClose={true}` and `props.hasBackdrop={false}`. | ||
*/ | ||
handleDocumentMousedown?: (e: MouseEvent) => void; | ||
|
||
/** Unique ID for this overlay which helps to identify it across prop changes. */ | ||
id: string; | ||
|
||
/** Subset of props necessary for some overlay stack focus management logic. */ | ||
props: Pick<OverlayProps, "autoFocus" | "enforceFocus" | "usePortal" | "hasBackdrop">; | ||
} |
Oops, something went wrong.
cbb705c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[core] fix(ContextMenuPopover): clean up document handlers on close (#6685)
Build artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job.