From 4a6f55e4d225cd496c1cc5264db50eb8587627ac Mon Sep 17 00:00:00 2001 From: Ryan Hinchey Date: Thu, 5 Jun 2025 11:36:08 -0400 Subject: [PATCH] fix: update link component to use navigateTo directly and support open in new tab --- ui/extensions/hello/src/components/link.js | 29 ++++++++++++++++------ ui/extensions/hello/src/dist/app.js | 17 ++++++++++--- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/ui/extensions/hello/src/components/link.js b/ui/extensions/hello/src/components/link.js index c845416..8ca0c82 100644 --- a/ui/extensions/hello/src/components/link.js +++ b/ui/extensions/hello/src/components/link.js @@ -1,18 +1,33 @@ import React, { useContext } from "react"; -import { Link as ReactRouterLink } from "react-router-dom"; +import { Link as ReactRouterLink } from "react-router-dom"; import { FalconApiContext } from "../contexts/falcon-api-context.js"; -function Link({ children, useFalconNavigation = false, to }) { - const { navigation } = useContext(FalconApiContext); +function Link({ + children, + useFalconNavigation = false, + to, + openInNewTab = false, +}) { + const { falcon, navigation } = useContext(FalconApiContext); + const absolutePath = falcon.bridge.targetOrigin.concat(to); + const onClick = (e) => { + e.preventDefault(); + navigation?.navigateTo({ + path: to, + type: "falcon", + target: openInNewTab ? "_blank" : "_self", + }); + }; if (useFalconNavigation) { return ( - {children} - ) + + {children} + + ); } - return {children} - + return {children}; } export { Link }; diff --git a/ui/extensions/hello/src/dist/app.js b/ui/extensions/hello/src/dist/app.js index 0e7f551..0c52538 100644 --- a/ui/extensions/hello/src/dist/app.js +++ b/ui/extensions/hello/src/dist/app.js @@ -5335,15 +5335,26 @@ function requireReactDom () { function Link({ children, useFalconNavigation = false, - to + to, + openInNewTab = false }) { const { + falcon, navigation } = reactExports.useContext(FalconApiContext); + const absolutePath = falcon.bridge.targetOrigin.concat(to); + const onClick = e => { + e.preventDefault(); + navigation?.navigateTo({ + path: to, + type: "falcon", + target: openInNewTab ? "_blank" : "_self" + }); + }; if (useFalconNavigation) { return /*#__PURE__*/React.createElement("a", { - onClick: navigation.onClick, - href: to + onClick: onClick, + href: absolutePath }, children); } return /*#__PURE__*/React.createElement(Link$1, {