-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(toolbar): Fix tooltip & hovercard & menu react-portal rendering i…
…nside the toolbar (#74797) What you can barely see here is a css change in the before & after shots. In the before there's no css applied. After there is some css (but z-index is too small, that's fixed in 37a40c6 in this PR) What's happening? We are importing a component that eventually calls, in the before case: `createPortal(..., document.body)`. The trouble with that is where the import happens. In the website codebase we import it and the whole react tree, including emotion css, is inside of `document`. But in this case we're importing it into toolbar code, so the react root starts inside our `ShadowRoot` reference instead of `document.body`. All our toolbar css is inside the shadowroot too, so when we use emotion and generate a className like `sentry-devtools-b0afu4` nodes mounted at `document` won't be able to access it. **TL/DR:** the portal target inside the toolbar needs to match with this snippet, using the same `container` value: https://github.com/getsentry/sentry/blob/6bb4638c3f24b9d737b80730561748874f4a7558/static/app/components/devtoolbar/components/providers.tsx#L23-L34, but only while we're developing inside sentry, and sharing components fully like this. **Before** ![SCR-20240723-nxfy](https://github.com/user-attachments/assets/f2690b8b-3315-4e19-a838-b4f178bfcf0f) **After** ![SCR-20240723-nxek](https://github.com/user-attachments/assets/80f4e159-cadb-4c1d-8479-933cb978275d)
- Loading branch information
Showing
6 changed files
with
47 additions
and
20 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
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,18 @@ | ||
import {createContext, type ReactNode, useContext} from 'react'; | ||
|
||
const ReactPortalTarget = createContext<HTMLElement | ShadowRoot>(document.body); | ||
|
||
interface Props { | ||
children: ReactNode; | ||
target: HTMLElement | ShadowRoot; | ||
} | ||
|
||
export function ReactPortalTargetProvider({children, target}: Props) { | ||
return ( | ||
<ReactPortalTarget.Provider value={target}>{children}</ReactPortalTarget.Provider> | ||
); | ||
} | ||
|
||
export default function useReactPortalTarget() { | ||
return useContext(ReactPortalTarget); | ||
} |
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