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

Function MenuSectionInner

packages/react-aria-components/src/Menu.tsx:454–499  ·  view source on GitHub ↗
(
  props: MenuSectionProps<T>,
  ref: ForwardedRef<HTMLElement>,
  section: Node<T>,
  className = 'react-aria-MenuSection'
)

Source from the content-addressed store, hash-verified

452}
453
454function MenuSectionInner<T>(
455 props: MenuSectionProps<T>,
456 ref: ForwardedRef<HTMLElement>,
457 section: Node<T>,
458 className = 'react-aria-MenuSection'
459) {
460 let state = useContext(MenuStateContext)!;
461 let {CollectionBranch} = useContext(CollectionRendererContext);
462 let [headingRef, heading] = useSlot();
463 let {headingProps, groupProps} = useMenuSection({
464 heading,
465 'aria-label': section.props['aria-label'] ?? undefined
466 });
467 let renderProps = useRenderProps({
468 ...props,
469 id: undefined,
470 children: undefined,
471 defaultClassName: className,
472 className: section.props?.className,
473 style: section.props?.style,
474 values: undefined
475 });
476
477 let parent = useContext(SelectionManagerContext)!;
478 let selectionState = useMultipleSelectionState(props);
479 let manager =
480 props.selectionMode != null ? new GroupSelectionManager(parent, selectionState) : parent;
481
482 let closeOnSelect = useSlottedContext(MenuItemContext)?.shouldCloseOnSelect;
483
484 let DOMProps = filterDOMProps(props as any, {global: true});
485 delete DOMProps.id;
486
487 return (
488 <dom.section {...mergeProps(DOMProps, renderProps, groupProps)} ref={ref}>
489 <Provider
490 values={[
491 [HeaderContext, {...headingProps, ref: headingRef}],
492 [SelectionManagerContext, manager],
493 [MenuItemContext, {shouldCloseOnSelect: props.shouldCloseOnSelect ?? closeOnSelect}]
494 ]}>
495 <CollectionBranch collection={state.collection} parent={section} />
496 </Provider>
497 </dom.section>
498 );
499}
500
501/**
502 * A MenuSection represents a section within a Menu.

Callers

nothing calls this directly

Calls 7

useSlotFunction · 0.90
useMenuSectionFunction · 0.90
useRenderPropsFunction · 0.90
useSlottedContextFunction · 0.90
filterDOMPropsFunction · 0.90
mergePropsFunction · 0.90

Tested by

no test coverage detected