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

Function handleLinkClick

packages/react-aria/src/utils/openLink.tsx:214–233  ·  view source on GitHub ↗
(
  e: ReactMouseEvent,
  router: Router,
  href: Href | undefined,
  routerOptions: RouterOptions | undefined
)

Source from the content-addressed store, hash-verified

212}
213
214export function handleLinkClick(
215 e: ReactMouseEvent,
216 router: Router,
217 href: Href | undefined,
218 routerOptions: RouterOptions | undefined
219): void {
220 // If a custom router is provided, prevent default and forward if this link should client navigate.
221 if (
222 !router.isNative &&
223 e.currentTarget instanceof HTMLAnchorElement &&
224 e.currentTarget.href &&
225 // If props are applied to a router Link component, it may have already prevented default.
226 !e.isDefaultPrevented() &&
227 shouldClientNavigate(e.currentTarget, e) &&
228 href
229 ) {
230 e.preventDefault();
231 router.open(e.currentTarget, e, href, routerOptions);
232 }
233}

Callers 2

useLinkFunction · 0.90
onClickFunction · 0.90

Calls 2

shouldClientNavigateFunction · 0.85
openMethod · 0.65

Tested by

no test coverage detected