You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an issue with this library with the positioning of the popover using my react-native app mounted on a web page under some content (this is reproductible by adding some margins on the root element).
I browse through the ContextMenu component and found out that the computePosition function could be enhanced by handling top and left coming from the windowLayout.
export const computePosition = (layouts, isRTL) => {
const { windowLayout, triggerLayout, optionsLayout } = layouts;
const {
x: wX,
y: wY,
width: wWidth,
height: wHeight,
top: wTop = 0, // top coming from window `onLayout` func defaulting to 0 when native
left: wLeft = 0, // left coming from window `onLayout` func defaulting to 0 when native
} = windowLayout;
const { x: tX, y: tY, height: tHeight, width: tWidth } = triggerLayout;
const { height: oHeight, width: oWidth } = optionsLayout;
const top = axisPosition(oHeight, wHeight, tY - wY, tHeight) - wTop; // fix the top position by removing the window top value
const left = axisPosition(oWidth, wWidth, tX - wX, tWidth) - wLeft; // fix the left position by removing the window left value
const start = isRTL ? "right" : "left";
const position = { top, [start]: left };
return fitPositionIntoSafeArea(position, layouts);
};
I will do a PR for this one but the workaround I have for now is to create a custom renderer based on the default one ContextMenu and change the computePosition func by the tweaked one.
The text was updated successfully, but these errors were encountered:
NoZiL
changed the title
[Feature] Handle window top and left
[Feature] Handle window top and left for react-native-web
Jan 21, 2021
Hey,
I ran into an issue with this library with the positioning of the popover using my react-native app mounted on a web page under some content (this is reproductible by adding some margins on the root element).
I browse through the
ContextMenu
component and found out that thecomputePosition
function could be enhanced by handlingtop
andleft
coming from thewindowLayout
.I will do a PR for this one but the workaround I have for now is to create a custom renderer based on the default one
ContextMenu
and change thecomputePosition
func by the tweaked one.The text was updated successfully, but these errors were encountered: