I've had initial success with using a FeatureLayer to query a point's geometry, manually setting the returned geometry as the popup's features. Then watching the view's scale and resetting the popup's location property using the popup's selectedFeature property. I also added a function to offset the popup anchor if you're using a symbol with a yoffset.
const createOffsetGeom = (args) => {
const { geometry, yoffset = 0, xoffset = 0 } = args;
const screenPoint = view.toScreen(geometry);
let offsetGeom = {};
screenPoint.y = screenPoint.y + yoffset;
screenPoint.x = screenPoint.x + xoffset;
offsetGeom = view.toMap(screenPoint)
return { latitude: offsetGeom.latitude, longitude: offsetGeom.longitude };
};
view.watch("scale", (scale) => {
if (view.popup.visible) {
view.popup.location = createOffsetGeom({ geometry:
view.popup.selectedFeature.geometry, yoffset: -18 });
}
});
It seems the geometry returned with hitTest is more generalized when you click on the map at smaller scale.