Skip to content

fix: open legal links in new tab #3613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/strange-cooks-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@reown/appkit-scaffold-ui': minor
'@reown/appkit-core': minor
---

Added legalLinksNewTab option to allow legal links to optionally open in new tabs
2 changes: 1 addition & 1 deletion apps/laboratory/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Obtain a project ID from https://cloud.walletconnect.com
NEXT_PUBLIC_PROJECT_ID=""
NEXT_PUBLIC_PROJECT_ID="ee7410d12dfbe505287359a4dd81ac22"
# See 1password for `NEXT_AUTH_SECRET`
NEXTAUTH_SECRET=""
# See 1password for `Mailsac AppKit API Key`
Expand Down
2 changes: 1 addition & 1 deletion apps/laboratory/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
9 changes: 9 additions & 0 deletions packages/core/src/controllers/OptionsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ export interface OptionsControllerStatePublic {
* @default false
*/
allowUnsupportedChain?: boolean
/**
* Open legal links (Terms and Privacy) in new tab
* @default false
*/
legalLinksNewTab?: boolean
}

export interface OptionsControllerStateInternal {
Expand Down Expand Up @@ -319,6 +324,10 @@ export const OptionsController = {
state.useInjectedUniversalProvider = useInjectedUniversalProvider
},

setLegalLinksNewTab(legalLinksNewTab: OptionsControllerState['legalLinksNewTab']) {
state.legalLinksNewTab = legalLinksNewTab
},

getSnapshot() {
return snapshot(state)
}
Expand Down
16 changes: 13 additions & 3 deletions packages/scaffold-ui/src/partials/w3m-legal-footer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export class W3mLegalFooter extends LitElement {
return null
}

return html`<a href=${termsConditionsUrl}>Terms of Service</a>`
const { target, rel } = this.getLinkAttributes()
return html`<a
href=${termsConditionsUrl}
?target=${target}
?rel=${rel}
>Terms of Service</a>`
}

private privacyTemplate() {
Expand All @@ -53,12 +58,17 @@ export class W3mLegalFooter extends LitElement {
return null
}

return html`<a href=${privacyPolicyUrl}>Privacy Policy</a>`
const { target, rel } = this.getLinkAttributes()
return html`<a
href=${privacyPolicyUrl}
?target=${target}
?rel=${rel}
>Privacy Policy</a>`
}
}

declare global {
interface HTMLElementTagNameMap {
'w3m-legal-footer': W3mLegalFooter
}
}
}
Loading