MCPcopy Create free account
hub / github.com/adobe/react-spectrum / PopoverInner

Function PopoverInner

packages/react-aria-components/src/Popover.tsx:223–401  ·  view source on GitHub ↗
({
  state,
  isExiting,
  UNSTABLE_portalContainer,
  clearContexts,
  ...props
}: PopoverInnerProps)

Source from the content-addressed store, hash-verified

221}
222
223function PopoverInner({
224 state,
225 isExiting,
226 UNSTABLE_portalContainer,
227 clearContexts,
228 ...props
229}: PopoverInnerProps) {
230 // Calculate the arrow size internally (and remove props.arrowSize from PopoverProps)
231 // Referenced from: packages/@react-spectrum/tooltip/src/TooltipTrigger.tsx
232 let arrowRef = useRef<HTMLDivElement>(null);
233 let containerRef = useRef<HTMLDivElement | null>(null);
234 let groupCtx = useContext(PopoverGroupContext);
235 let isSubPopover = groupCtx && props.trigger === 'SubmenuTrigger';
236
237 let [isOpen, setIsOpen] = useState(false);
238
239 let {popoverProps, underlayProps, arrowProps, placement, triggerAnchorPoint} = usePopover(
240 {
241 ...props,
242 offset: props.offset ?? 8,
243 arrowRef,
244 // If this is a submenu/subdialog, use the root popover's container
245 // to detect outside interaction and add aria-hidden.
246 groupRef: isSubPopover ? groupCtx! : containerRef
247 },
248 state
249 );
250
251 let ref = props.popoverRef as RefObject<HTMLDivElement | null>;
252 // Skip the automatic entry animation when opening instantly (e.g. swapping between previews
253 // during warmup). An explicitly provided isEntering prop still takes precedence.
254 let enterAnimation = useEnterAnimation(ref, !!placement && isOpen);
255 // oxlint-disable-next-line react/react-compiler
256 let isEntering = props.isEntering || (!props.shouldSkipAnimation && enterAnimation) || false;
257 // oxlint-disable-next-line react/react-compiler
258 let renderProps = useRenderProps({
259 // oxlint-disable-next-line react/react-compiler
260 ...props,
261 defaultClassName: 'react-aria-Popover',
262 // oxlint-disable-next-line react/react-compiler
263 values: {
264 // oxlint-disable-next-line react/react-compiler
265 trigger: props.trigger || null,
266 placement,
267 // oxlint-disable-next-line react/react-compiler
268 isEntering,
269 isExiting
270 }
271 });
272
273 // Automatically render Popover with role=dialog except when isNonModal is true,
274 // or a dialog is already nested inside the popover.
275 let shouldBeDialog =
276 // oxlint-disable-next-line react/react-compiler
277 !props.isNonModal || props.trigger === 'SubmenuTrigger' || props.trigger === 'PreviewTrigger';
278 // oxlint-disable-next-line react/react-compiler
279 let [isDialog, setDialog] = useState(props.trigger === 'PreviewTrigger');
280 useLayoutEffect(() => {

Callers

nothing calls this directly

Calls 10

usePopoverFunction · 0.90
useEnterAnimationFunction · 0.90
useRenderPropsFunction · 0.90
getInteractionModalityFunction · 0.90
isFocusWithinFunction · 0.90
focusSafelyFunction · 0.90
useResizeObserverFunction · 0.90
runAfterKeyboardFunction · 0.90
mergePropsFunction · 0.90
filterDOMPropsFunction · 0.90

Tested by

no test coverage detected