Skip to content
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

update with main #7900

Open
wants to merge 99 commits into
base: next-release/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
c0de6d8
Update versions.ts Android Amplify V2.19.1 (#7767)
lawmicha Jun 21, 2024
f6eb7bc
chore(flutter): update android section of Amplify Flutter getting sta…
Jordan-Nelson Jun 21, 2024
f75809d
update mobile quickstarts with link to fullstack branch deployment gu…
josefaidt Jun 24, 2024
ddd3717
chore: add serverComponentsExternalPackages callout for Next.js (#7757)
HuiSF Jun 24, 2024
0cee76e
add warning callout to gen1 backend-config (#7773)
josefaidt Jun 25, 2024
be293f5
Revert "chore: add region to scrollable table (#7744)" (#7784)
hbuchel Jun 27, 2024
2ee5be3
chore: change outputs to amplifyConfig in flutter gen 2 docs (#7764)
khatruong2009 Jun 28, 2024
a640904
fix: heading order on gen1/prev subscribe-data page (#7790)
hbuchel Jul 1, 2024
9e79e97
add warning regarding subscription and mutation redaction of relation…
chrisbonifacio Jul 1, 2024
03372e2
fix subscriptionsInheritPrimaryAuth default value (#7795)
dpilch Jul 2, 2024
3298bba
change overview card titles from p to h2 (#7780)
katiegoines Jul 2, 2024
c550c19
remove conditional in aria-describedby={codeId} for MDXCopyCodeButton…
katiegoines Jul 2, 2024
9a5e77f
Update index.mdx to fix typo (#7798)
swaminator Jul 2, 2024
6c697ee
add workflow to validate redirects (#7726)
katiegoines Jul 3, 2024
6efa947
update set up function guide with data example (#7759)
josefaidt Jul 4, 2024
6966a11
remove checkboxes and circle (#7783)
ykethan Jul 5, 2024
09779ce
fix: heading order (#7803)
hbuchel Jul 5, 2024
1fba05c
restore autoSignIn section for SignIn page, and Switching Authenticat…
joon-won Jul 5, 2024
2548f29
replace `amplify` to `ampx` (#7804)
fossamagna Jul 8, 2024
8bda64e
feat(js): list api subpathStrategy parameter (#7794)
haverchuck Jul 9, 2024
cc6e6f8
chore: update domains for proxy (#7808)
0618 Jul 9, 2024
14caad4
fix: typo on client code generation page (#7809)
hbuchel Jul 9, 2024
5c25e92
Fix anchor link, add some scroll margin to h4 headings (#7810)
hbuchel Jul 9, 2024
597ddd4
chore(deps): bump @aws-amplify/amplify-cli-core from 4.3.8 to 4.3.9 (…
dependabot[bot] Jul 10, 2024
1e1c5db
chore(deps): bump aws-actions/aws-secretsmanager-get-secrets (#7792)
dependabot[bot] Jul 10, 2024
96f9f1f
storage(android): update getURL options (#7736)
phantumcode Jul 11, 2024
c454d67
Add Gen 2 SDL docs (#7793)
dpilch Jul 12, 2024
729c600
Cbonif/add-non-model-auth-section (#7817)
chrisbonifacio Jul 12, 2024
83e1a25
add auth permissions (#7796)
ykethan Jul 12, 2024
3372bca
callout for mysql/postgres custom query return types (#7813)
chrisbonifacio Jul 12, 2024
539f79f
Clarify Manual Loading of Environment Variables in Sandbox Environmen…
ashphy Jul 16, 2024
91dacfa
fix data env name in function example, ref #7825 (#7826)
josefaidt Jul 16, 2024
d230333
Update app id reference for CI/CD deployments (#7832)
Jay2113 Jul 17, 2024
d955bc2
fix(swift): updated concurrency in quickstart (#7828)
sebsto Jul 18, 2024
fa7c5e1
chore(android): Update versions.ts - Android SDK 2.76.0(#7833)
lawmicha Jul 18, 2024
0863c08
feat(Swift): Adding SubpathStrategy documentation for Storage.List (#…
ruisebas Jul 18, 2024
4a8ce41
Add Gen1 banner to getting started pages (#7839)
jacoblogan Jul 22, 2024
8ab9f63
remove temporary disabling of copy-code button (#7835)
katiegoines Jul 22, 2024
e7b3a8a
add streaming function logs docs (#7841)
josefaidt Jul 22, 2024
279ce2c
a11y-when closing accordion from bottom, focus back on summary elemen…
katiegoines Jul 22, 2024
8be7f89
a11y-remove alt text for decorative image (#7836)
katiegoines Jul 22, 2024
d49a16b
Update index.mdx (#7840)
takaya-okamoto Jul 22, 2024
d24c120
put feedback responses in aria-live (#7844)
katiegoines Jul 23, 2024
383ee7c
when clicking on toc entry, focus on respective heading in content (#…
katiegoines Jul 23, 2024
a4e7b13
add scheduling functions docs (#7842)
josefaidt Jul 25, 2024
ab3d9e9
add docs for auth custom attribute support (#7846)
josefaidt Jul 26, 2024
39d697c
remove studio reference in Amplify Gen 2 docs (#7860)
ykethan Jul 30, 2024
ddf6d02
storage(android): update storage list with delimiter support (#7830)
phantumcode Jul 30, 2024
57cec00
Add resolution for fast-xml-parser (#7859)
esauerbo Jul 30, 2024
2264eff
a11y videos have aria-hidden but can still receive focus (#7866)
katiegoines Aug 2, 2024
dece79a
chore(flutter): added push notifications snippet for updated settings…
khatruong2009 Aug 5, 2024
7d329ee
fix: change gen2 monorepo setting image path (#7786)
magisystem0408 Aug 6, 2024
0a5b4ac
adds storage, user and data management pages (#7814)
ykethan Aug 6, 2024
5bae7b0
add non-dev mode info to figma to react docs (#7878)
ykethan Aug 7, 2024
4173f13
rework "use existing cognito resources" prose, highlight configuring …
josefaidt Aug 7, 2024
5ac6f98
a11y- add more descriptive text to learn more in gen2 modal (#7869)
katiegoines Aug 8, 2024
9ea374e
a11y - add aria-label to external link instances (#7874)
katiegoines Aug 12, 2024
40a61d1
add id to popovertrigger (#7881)
katiegoines Aug 12, 2024
2ddbb87
fix: removed hyphen from the logGroupName (#7856)
AnilMaktala Aug 13, 2024
e13b295
updating axios dependency to use new safe version (#7886)
jordanvn Aug 14, 2024
9e6e755
update cdk bootstrap cmd (#7889)
0618 Aug 14, 2024
59432ba
Add Docs for Email Invitation Customization (#7891)
grahamjamesr7 Aug 15, 2024
f329cce
[Multi-bucket] Storage - add multi bucket setup and usage examples (#…
jjarvisp Aug 15, 2024
2afa543
remove untrue claim about device tracking (#7898)
sobolk Aug 20, 2024
4f094c6
Feat (Auth): added docs for fetchCurrentDevice API (#7737)
hahnandrew Aug 20, 2024
3bda977
fix: update handler to use correct environment variable format (#7771)
jhorvat7 Aug 20, 2024
ac05ca9
modify commeting for copy convenience (#7875)
moonchanyong Aug 21, 2024
3a21b61
fix heading levels (#7906)
katiegoines Aug 21, 2024
c38b108
fixed: file path for the Backfill your OpenSearch index script. (#7911)
AnilMaktala Aug 23, 2024
9183a63
rm .default() in argument for set up function guide (#7910)
josefaidt Aug 23, 2024
a11a9e0
Update headers and CSP value (#7904)
jacoblogan Aug 27, 2024
4f081f7
Revert "Update headers and CSP value (#7904)" (#7920)
jacoblogan Aug 27, 2024
5691d81
add confirm sign in snippet #7782 (#7787)
josefaidt Aug 28, 2024
61b4bfd
update maplibre options links (#7924)
jacoblogan Aug 29, 2024
e72eead
feat: custom SSL CA support for SQL data sources (#7802)
palpatim Aug 29, 2024
a85dde6
fix(analytics): add update iam policy section to existing resources p…
NikaHsn Aug 30, 2024
5d4cdd9
fix cron format (#7931)
josefaidt Sep 4, 2024
cfb8a2f
fix(dependabot): update yarn.lock for micromatch version to 4.0.8 (#7…
thaddmt Sep 4, 2024
5ba9551
Update callout warning for RN Push Notification (#7923)
yuhengshs Sep 4, 2024
19e99c4
fix(vue): Update data setup guide for Vue, remove tsx (#7727)
ErikCH Sep 4, 2024
073215b
Fixed a missing parameter error in the EventBridgeHandler example cod…
Tak1wa Sep 5, 2024
b6784bb
chore: Rename Storage Manager to File Uploader (#7921)
jordanvn Sep 5, 2024
0ec7e62
fix typo in backend auth sample (#7903)
Amplifiyer Sep 6, 2024
2053da0
a11y- Callouts should use descriptive text for icons (#7882)
katiegoines Sep 6, 2024
bca62c6
fix dynamodb lambda stream setup (#7917)
dpilch Sep 9, 2024
3092127
Add troubleshooting for missing real-time event data (#7955)
svidgen Sep 10, 2024
6c6ce5c
chore: add information about the new signOut redirect url option (#7938)
Samaritan1011001 Sep 10, 2024
5c34f48
chore(deps): bump @aws-amplify/ui-react from 6.1.12 to 6.3.1 (#7963)
dependabot[bot] Sep 12, 2024
8b682d1
Added an example page for setting up custom-auth-flows (#7947)
yuhengshs Sep 12, 2024
62edafe
add explainer for function env file generation (#7957)
josefaidt Sep 16, 2024
e53ca20
fix(security) remove serve dev dependency (#7967)
jordanvn Sep 16, 2024
32e0403
docs(data): add async function handlers section to custom queries and…
atierian Sep 17, 2024
f490314
fix cutoff words in viewports under 320px (#7942)
katiegoines Sep 17, 2024
2f191dc
chore(js): add js sdk recommendation for server use cases (#7968)
haverchuck Sep 18, 2024
c4e84c7
Update next.js version (#7974)
esauerbo Sep 19, 2024
91920b4
feat(local setup): Added a video to configure AWS for local developme…
ErikCH Sep 19, 2024
24fc529
fix(grammar): a to an in Authentication-Concepts (#7977)
edisooon Sep 19, 2024
a072e21
improve callout for group access in storage (#7973)
hdworld11 Sep 19, 2024
ca792f9
storage: update android and swift storage category with multiple buck…
phantumcode Sep 19, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/check_for_broken_links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
role-to-assume: arn:aws:iam::464149486631:role/github_action_read_slack_webhook_url
aws-region: us-west-2
- name: Read secrets from AWS Secrets Manager into environment variables
uses: aws-actions/aws-secretsmanager-get-secrets@ff26a0aa6bd4dd5e51326b5afb3f5f6874c958c7 # v2.0.3
uses: aws-actions/aws-secretsmanager-get-secrets@98c2d6bf1dd67c2575fa2bb14294aa64103d426c # v2.0.5
with:
secret-ids: |
SLACK_WEBHOOK_URL
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/scripts/validate-redirects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module.exports = {
invalidRedirects: () => {
const Ajv = require('ajv');
const redirects = require('../../../redirects.json');
const ajv = new Ajv();

const schema = {
type: 'array',
items: {
type: 'object',
required: ['source', 'target', 'status'],
properties: {
source: {
description: 'The address the user requested.',
type: 'string',
pattern: '^/'
},
target: {
description:
'The address that actually serves the content that the user sees',
type: 'string',
pattern: '^[(https)(/)]'
},
status: {
description:
'Types include a permanent redirect (301), a temporary redirect (302), a rewrite (200), or not found (404).',
type: 'string',
pattern: '^[0-5-]+$'
}
}
}
};

const errors = [];
const validate = ajv.compile(schema);

const validateEntries = (redirects) => {
const valid = validate(redirects);

if (!valid) {
const error = validate.errors[0];
const invalidEntry =
JSON.stringify(redirects[error.instancePath.slice(1, -7)]);
const loc = error.schemaPath.slice(error.schemaPath.indexOf('properties') + 11, -8);
const errorMessage = '\n\n' + 'INVALID ENTRY: Please correct the error in the "' + loc +'" property of the following entry: \n' + invalidEntry + '\n' + 'ERROR MESSAGE: ' + error.message;
errors.push(errorMessage);

validateEntries(redirects.splice(parseInt(error.instancePath.slice(1, -7)) + 1));

}
}
validateEntries(redirects);

return errors;
}
}


32 changes: 32 additions & 0 deletions .github/workflows/validate_redirects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Validate Redirects
on:
pull_request:
branches: [main]
types: [opened, synchronize]
env:
BUILD_DIR: 'client/www/next-build'
permissions:
contents: read
jobs:
ValidateRedirects:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
- name: Install Dependencies
run: yarn
- name: Validate redirects
id: redirects
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
result-encoding: string
script: |
const { invalidRedirects } = require('./.github/workflows/scripts/validate-redirects.js');
return await invalidRedirects();
- name: Fail if any invalid redirects have been found
if: ${{ steps.redirects.outputs.result }}
run: exit 1 && echo ${{ steps.redirects.outputs.result }}
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ let mut a = String::from("a");
Videos can be added using the `<Video />` component and referencing a path to the video file. The video should be an `.mp4` file and should exist in the `/public` directory

```jsx
<Video src="/path/to/video.mp4" />
<Video src="/path/to/video.mp4" description="Video - [video description]" />
```

## Accessibility testing
Expand Down
5 changes: 4 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,12 @@
"Didfinishlaunchingwithoptions",
"displayMode",
"displayOrder",
"dists",
"DocSet",
"DocSets",
"Donef",
"Dont",
"dotenvx",
"downcasting",
"dropdown",
"dynamoDB",
Expand Down Expand Up @@ -593,6 +595,7 @@
"Figma",
"Figma's",
"figma",
"fileuploader",
"architected",
"newsfeeds",
"textareas",
Expand Down Expand Up @@ -1242,7 +1245,6 @@
"Storage.put",
"storagebucketname",
"storagedemo",
"storagemanager",
"storageOptions",
"storagepath",
"StoragePath",
Expand Down Expand Up @@ -1394,6 +1396,7 @@
"validationData",
"vanillajs",
"varchar",
"vendedlogs",
"verify.js",
"VerifyAuthChallengeResponse",
"VeriSign",
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"license": "Apache-2.0",
"private": true,
"dependencies": {
"@aws-amplify/amplify-cli-core": "^4.3.8",
"@aws-amplify/ui-react": "^6.1.12",
"@aws-amplify/amplify-cli-core": "^4.3.9",
"@aws-amplify/ui-react": "^6.3.1",
"@docsearch/react": "3",
"ajv": "^8.16.0",
"aws-amplify": "^6.0.9",
"next": "^14.2.3",
"next-image-export-optimizer": "^1.8.3",
Expand Down Expand Up @@ -41,7 +42,7 @@
"@types/react": "^18.0.0",
"@types/url-parse": "^1.4.3",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"axios": "^1.3.4",
"axios": "^1.7.4",
"cheerio": "^1.0.0-rc.12",
"classnames": "^2.3.2",
"cross-env": "^7.0.3",
Expand Down Expand Up @@ -74,7 +75,6 @@
"remark-mdx-searchable": "^0.1.3",
"rollup-plugin-node-polyfills": "^0.2.1",
"sass": "^1.77.5",
"serve": "^14.2.1",
"tiny-glob": "0.2.9",
"ts-jest": "^29.1.2",
"ts-node": "^8.5.0",
Expand All @@ -88,7 +88,7 @@
"loader-utils": "2.0.4",
"minimatch": "3.1.2",
"decode-uri-component": "0.2.1",
"fast-xml-parser": "4.2.5",
"**/fast-xml-parser": "4.4.1",
"semver": "7.5.2",
"tough-cookie": "4.1.3",
"aws-cdk-lib": "2.80.0",
Expand Down
Binary file modified public/images/gen2/fullstack-branching/monorepo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/gen2/manage/data-manager.mp4
Binary file not shown.
Binary file added public/images/gen2/manage/storage-manager.mp4
Binary file not shown.
Binary file added public/images/gen2/manage/user-manager.mp4
Binary file not shown.
4 changes: 2 additions & 2 deletions redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
},
{
"source": "/ui/storage/s3-image-picker/q/framework/<platform>/",
"target": "https://ui.docs.amplify.aws/react/connected-components/storage/storagemanager",
"target": "https://ui.docs.amplify.aws/react/connected-components/storage/fileuploader",
"status": "302"
},
{
Expand Down Expand Up @@ -3011,7 +3011,7 @@
},
{
"source": "/lib/client-configuration/configuring-amplify-categories/q/platform/react-native/",
"target": "react-native/tools/libraries/configure-categories/",
"target": "/react-native/tools/libraries/configure-categories/",
"status": "301"
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ export const Accordion: React.FC<AccordionProps> = ({

const closeAccordion = () => {
const details = detailsRef.current;
const summary = summaryRef.current;
if (details) {
const scrollToLoc = details.offsetTop - 48 - 70 - 10; // account for nav heights and 10px buffer
setDetailsOpen(false);
details.animate(collapse, animationTiming);
summary?.focus();
window.scrollTo({
left: 0,
top: scrollToLoc,
Expand Down
5 changes: 4 additions & 1 deletion src/components/Accordion/__tests__/Accordion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ describe('Accordion', () => {
});
});

it('should collapse Accordion when close button is clicked', async () => {
it('should collapse Accordion and refocus on Accordion element when close button is clicked', async () => {
render(component);
const accordionHeading = screen.getByText('Accordion component example');
userEvent.click(accordionHeading);
const detailsEl = await screen.getByRole('group');
const summaryEl = detailsEl.firstChild;

expect(detailsEl).toHaveAttribute('open');

const text = await screen.getByText(content);
Expand All @@ -79,6 +81,7 @@ describe('Accordion', () => {
await waitFor(() => {
expect(text).not.toBeVisible();
expect(detailsEl).not.toHaveAttribute('open');
expect(summaryEl).toHaveFocus();
});
});

Expand Down
28 changes: 24 additions & 4 deletions src/components/Callout/Callout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
import { Message, View } from '@aws-amplify/ui-react';
import { Flex, Message } from '@aws-amplify/ui-react';
import { IconWarning, IconInfo } from '../Icons';

interface CalloutProps {
info?: boolean;
warning?: boolean;
backgroundColor?: string;
children?: React.ReactNode;
}

export const Callout = ({ warning, children }: CalloutProps) => {
export const Callout = ({
warning,
backgroundColor,
children
}: CalloutProps) => {
return (
<Message variation="filled" colorTheme={warning ? 'warning' : 'info'}>
<View>{children}</View>
<Message
variation="filled"
colorTheme={warning ? 'warning' : 'info'}
backgroundColor={backgroundColor}
hasIcon={false}
>
<Flex>
<div className="amplify-message__icon">
{warning ? (
<IconWarning aria-hidden={false} aria-label="Warning" />
) : (
<IconInfo aria-hidden={false} aria-label="Important information" />
)}
</div>
<div className="amplify-message__content">{children}</div>
</Flex>
</Message>
);
};
12 changes: 12 additions & 0 deletions src/components/Callout/__tests__/Callout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@ describe('Callout', () => {

consoleErrorFn.mockRestore();
});

it('should pass the backgroundColor through to the Message component', async () => {
const child = <div>Callout Child</div>;
const ele = render(
<Callout info={true} backgroundColor={'red'}>
{child}
</Callout>
);

const styles = getComputedStyle(ele.container.children[0]);
expect(styles.backgroundColor).toBe('red');
});
});
13 changes: 10 additions & 3 deletions src/components/ExternalLink/__tests__/ExternalLink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,27 @@ describe('ExternalLink', () => {
it('should render the ExternalLink component', async () => {
render(component);
const externalLink = await screen.getByRole('link', {
name: 'Click Here!'
name: '(opens in new tab)'
});
const externalLinkText = await screen.findByText('Click Here!');

expect(externalLink).toBeInTheDocument();
await waitFor(() => {
expect(externalLink).toBeInTheDocument();
expect(externalLinkText).toBeInTheDocument();
});
});

it('should open external links in a new window', async () => {
render(component);
const externalLink = await screen.getByRole('link', {
name: 'Click Here!'
name: '(opens in new tab)'
});
const externalLinkText = await screen.findByText('Click Here!');

expect(externalLink).toHaveAttribute('rel', 'noopener noreferrer');
expect(externalLink).toHaveAttribute('target', '_blank');
expect(externalLinkText).toHaveAttribute('rel', 'noopener noreferrer');
expect(externalLinkText).toHaveAttribute('target', '_blank');
});

it('should trackExternalLink on click', async () => {
Expand Down
14 changes: 13 additions & 1 deletion src/components/ExternalLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useRef } from 'react';
import { trackExternalLink } from '../../utils/track';

type ExternalLinkProps = {
Expand All @@ -15,15 +15,27 @@ const ExternalLink: React.FC<ExternalLinkProps> = ({
href,
className
}) => {
const [label, setLabel] = React.useState('');
const linkRef = useRef<HTMLAnchorElement>(null);

useEffect(() => {
if (linkRef.current) {
const text = linkRef.current.innerText;
setLabel(text ? text : '');
}
}, []);

return (
<a
href={href}
className={className}
aria-label={label + ' (opens in new tab)'}
rel="noopener noreferrer"
target="_blank"
onClick={() => {
trackLink(href);
}}
ref={linkRef}
>
{children}
</a>
Expand Down
14 changes: 14 additions & 0 deletions src/components/ExternalLinkButton/ExternalLinkButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Button, ButtonProps } from '@aws-amplify/ui-react';
import { IconExternalLink } from '../Icons';
import { trackExternalLink } from '../../utils/track';
import { useEffect, useRef } from 'react';
import React from 'react';

interface ExternalLinkButtonProps {
variation?: ButtonProps['variation'];
Expand All @@ -21,6 +23,16 @@ export const ExternalLinkButton = ({
children,
className
}: ExternalLinkButtonProps) => {
const [label, setLabel] = React.useState('');
const buttonRef = useRef<HTMLAnchorElement>(null);

useEffect(() => {
if (buttonRef.current) {
const text = buttonRef.current.innerText;
setLabel(text ? text : '');
}
}, []);

return (
<Button
href={href}
Expand All @@ -32,9 +44,11 @@ export const ExternalLinkButton = ({
as="a"
align-items="center"
className={className}
aria-label={label + ' (opens in new tab)'}
onClick={() => {
trackLink(href);
}}
ref={buttonRef}
>
{children} <IconExternalLink />
</Button>
Expand Down
Loading