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

Function handleLinkClick

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

Source from the content-addressed store, hash-verified

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

Callers 2

useLinkFunction · 0.90
onClickFunction · 0.90

Calls 2

shouldClientNavigateFunction · 0.85
openMethod · 0.65

Tested by

no test coverage detected