I think I figured it out.
We had been making custom popups using 2 features of the built-in popup
So when the header moved inside the shadow DOM, we got stuck.
After some experiments, it turned out the solution is actually quite simple
we do not use the Popup’s content property
we instead use the container property to render our custom popup
we hide the “entire” default popup by overriding the relevant CSS
import React from 'react'
import { createPortal } from 'react-dom';
import './App.css'
import MapView from '@arcgis/core/views/MapView';
import Map from '@arcgis/core/Map';
import Popup from "@arcgis/core/widgets/Popup.js";
/*
The important stuff
// if you do not do this, the popup will only stay in one (center top) anchor
// if you do this, the anchor will change out of the box as you move around the map
.esri-popup__main-container {
height: 0px;
display: contents !important;
}
.esri-popup__main-container > .esri-widget--panel {
display: none;
}
on your custom popup, z-index is required to ensure the popup renders over the popup-pointer
*/
const CustomPopup = (props) => {
return (
// z-index is required to ensure popup renders over the popup-pointer
<div style={{ zIndex: 1, backgroundColor: 'white', padding: '20px' }}>
This is my custom JSX Component popup
</div>
)
};
const PopupPortal = ({ mount, children }) => {
return createPortal(children, mount);
};
const App = () => {
const popupRoot = document.createElement("div");
React.useEffect(() => {
const mapView = new MapView({
container: "mapDiv",
map: new Map({
basemap: "streets-navigation-vector"
})
});
mapView.popup = new Popup({
actions: [],
container: popupRoot,
});
mapView.popupEnabled = false;
mapView.on("click", (event) => {
mapView.openPopup({
location: event.mapPoint
});
});
}, [])
return (
<div id="mapDiv">
<PopupPortal mount={popupRoot}>
<CustomPopup />
</PopupPortal>
</div>
)
}
export default App