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

Function Popover

packages/react-aria/stories/select/example.tsx:61–96  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

59}
60
61function Popover(props) {
62 let ref = React.useRef(undefined);
63 let {popoverRef = ref, isOpen, onClose, children} = props;
64
65 // Handle events that should cause the popup to close,
66 // e.g. blur, clicking outside, or pressing the escape key.
67 let {overlayProps} = useOverlay(
68 {
69 isOpen,
70 onClose,
71 shouldCloseOnBlur: true,
72 isDismissable: true
73 },
74 popoverRef
75 );
76
77 // Add a hidden <DismissButton> component at the end of the popover
78 // to allow screen reader users to dismiss the popup easily.
79 return (
80 <FocusScope restoreFocus>
81 <div
82 {...overlayProps}
83 ref={popoverRef}
84 style={{
85 position: 'absolute',
86 width: '100%',
87 border: '1px solid gray',
88 background: 'lightgray',
89 marginTop: 4
90 }}>
91 {children}
92 <DismissButton onDismiss={onClose} />
93 </div>
94 </FocusScope>
95 );
96}
97
98function ListBox(props) {
99 let ref = React.useRef(undefined);

Callers

nothing calls this directly

Calls 1

useOverlayFunction · 0.90

Tested by

no test coverage detected