Skip to content

Commit

Permalink
fix: fix RouteLink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Apr 12, 2024
1 parent d1cdd80 commit 6ecb166
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default defineConfig({
},
})
},
experimentalRunAllSpecs: true,
},
env: {
E2E_BASE: process.env.E2E_BASE ?? '/',
Expand Down
25 changes: 24 additions & 1 deletion packages/client/src/components/RouteLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ const guardEvent = (event: MouseEvent): boolean | void => {
return true
}

export interface RouteLinkProps {
/**
* Whether the link is active to have an active class
*
* Notice that the active status is not automatically determined according to the current route.
*
* @default false
*/
active?: boolean

/**
* The class to add when the link is active
*
* @default 'route-link-active'
*/
activeClass?: string

/**
* The route path to link to
*/
to: string
}

/**
* Component to render a link to another route.
*
Expand Down Expand Up @@ -80,7 +103,7 @@ export const RouteLink = defineComponent({
href: path.value,
onClick: (event: MouseEvent = {} as MouseEvent) => {
if (guardEvent(event)) {
router.push(path.value).catch()
router.push(props.to).catch()
}
},
},
Expand Down

0 comments on commit 6ecb166

Please sign in to comment.