MCPcopy Index your code
hub / github.com/adobe/react-spectrum / onClick

Function onClick

packages/react-aria/src/menu/useMenuItem.ts:256–277  ·  view source on GitHub ↗
(e: MouseEvent<FocusableElement>)

Source from the content-addressed store, hash-verified

254 };
255
256 let onClick = (e: MouseEvent<FocusableElement>) => {
257 onClickProp?.(e);
258 performAction();
259 handleLinkClick(e, router, item!.props.href, item?.props.routerOptions);
260
261 let shouldClose =
262 interaction.current?.pointerType === 'keyboard'
263 ? // Always close when pressing Enter key, or if item is not selectable.
264 interaction.current?.key === 'Enter' ||
265 selectionManager.selectionMode === 'none' ||
266 selectionManager.isLink(key)
267 : // Close except if multi-select is enabled.
268 selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key);
269
270 shouldClose = shouldCloseOnSelect ?? closeOnSelect ?? shouldClose;
271
272 if (onClose && !isTrigger && shouldClose) {
273 onClose();
274 }
275
276 interaction.current = null;
277 };
278
279 let {itemProps, isFocused} = useSelectableItem({
280 id,

Callers

nothing calls this directly

Calls 3

handleLinkClickFunction · 0.90
performActionFunction · 0.70
isLinkMethod · 0.65

Tested by

no test coverage detected