From cc235fda057850561848d91793ca17ea58607856 Mon Sep 17 00:00:00 2001 From: Jeremy Neal Date: Thu, 22 Jun 2023 11:13:12 -0400 Subject: [PATCH] Accessibility engineering review for Link component. (#3317) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove as prop from Link. * Underline Link when inside of a paragraph tag, hover behavior should match focus behavior. * Create curly-otters-repeat.md * Soft deprecate as prop for Link so we don't break compatibility. * Fix issues with Link-dependent components when as prop is not accepted. * Remove ReactRouterLikeLink function from NavList tests. * Remove references to as prop from Link docs. * Update generated/components.json * Remove reference to as prop in ActionList.LinkItem docs. * Update generated/components.json * Add link variant to button to match PVC implementation. * Update generated/components.json * Allow up to 4 levels of nesting for the NavList (#3343) * allows up to 4 levels of nesting for the NavList * adds changeset * Update src/NavList/NavList.tsx Co-authored-by: Cole Bemis * updates snapshots --------- Co-authored-by: Cole Bemis * Refactor(ActionList): ActionList.Item should render content as a button if parent is not interactive. (#3284) * Using button as the underlying tag for ActionList.Item content. * Fix subnav layout. * Changing ActionList content to button if the top-level is not a button. ActionMenu is busted. * Fix issue where ActionList.Item content would render as a button inside ActionMenu, breaking keyboard navigation. * Create purple-crabs-matter.md * test(vrt): update snapshots * Fix bug with MenuContext not being exported properly. * Fix color violation in ActionList.Item. * Formatting, update snapshots. * test(vrt): update snapshots * Fix a11y violation in ActionList story. * Formatting. * Fix ts-ignore comment. * Adjust line-height when button is rendered. * Revert "test(vrt): update snapshots" This reverts commit ba6d863a69341e0792f44f0185dc336e298775dc. * Revert "test(vrt): update snapshots" This reverts commit 31d5358ad85ef83803434aaa09ea016602337e0d. * Update snapshots. * Remove flexGrow from ActionList.Item to remove extra 1px vertical height. * Set padding to 0 and put flexGrow back to fix padding issue for ActionList buttons. * Fix ActionList text wrap story. * Fix underlinenav story by checking ActionList.Item if as prop is a. * Update snapshots and formatting. * Update snapshots. * If ActionList.Item content is rendered as a button, remove tabIndex from li and fix padding. * Fix various layout edge cases. * ts-ignore event handlers on ItemWrapper. * Update snapshots. * Revert fontWeight config that differed from production docs. * Pass selectionVariant prop illegally in UnderlineNav story to fix issue with Selection spans showing up. * fix: prevent closing menu when `event.preventDefault()` is called on `ActionList.Item`'s `onSelect` handler by @gr2m (#3346) * fix: prevent closing menu when `event.preventDefault()` is called on `ActionList.Item`'s `onSelect` handler (#3163) * test: prevent closing menu when `event.preventDefault()` is called on `ActionList.Item`'s `onSelect` handler Failing test for https://github.com/primer/react/issues/3162 * fix: prevent closing menu when `event.preventDefault()` is called on `ActionList.Item`ߴs `onSelect` handler * add storybook example: Delayed Menu Close * update docs * docs: changeset * Update changelog --------- Co-authored-by: Siddharth Kshetrapal * Update generated/components.json --------- Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com> Co-authored-by: siddharthkp * Check for tabIndex value in isTopLevelInteractive. * Reference styles in updated menuProps. * Updated snapshots. * Fix padding setting instead of using values from styles, which are inverted. * Update snapshots. --------- Co-authored-by: radglob Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com> Co-authored-by: siddharthkp * Rollback attempt at underlying links inside other bits of text. * Update src/Button/styles.ts Co-authored-by: Katie Langerman <18661030+langermank@users.noreply.github.com> --------- Co-authored-by: radglob Co-authored-by: Mike Perrotti Co-authored-by: Cole Bemis Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com> Co-authored-by: siddharthkp Co-authored-by: Katie Langerman <18661030+langermank@users.noreply.github.com> --- .changeset/curly-otters-repeat.md | 6 + docs/content/Link.mdx | 4 - generated/components.json | 14 +- src/ActionList/ActionList.docs.json | 5 - src/ActionList/LinkItem.tsx | 14 +- src/Button/Button.docs.json | 4 +- src/Button/Button.stories.tsx | 2 +- src/Button/styles.ts | 19 +++ src/Button/types.ts | 2 +- src/Link/Link.docs.json | 9 +- src/Link/Link.features.stories.tsx | 20 ++- src/Link/Link.tsx | 46 ++---- src/Link/__tests__/Link.test.tsx | 15 +- .../__snapshots__/Link.test.tsx.snap | 134 ++---------------- src/NavList/NavList.test.tsx | 15 +- .../__snapshots__/NavList.test.tsx.snap | 80 ++--------- src/PageHeader/PageHeader.tsx | 8 +- .../__snapshots__/SideNav.test.tsx.snap | 20 +-- 18 files changed, 97 insertions(+), 320 deletions(-) create mode 100644 .changeset/curly-otters-repeat.md diff --git a/.changeset/curly-otters-repeat.md b/.changeset/curly-otters-repeat.md new file mode 100644 index 00000000000..2504ec46af7 --- /dev/null +++ b/.changeset/curly-otters-repeat.md @@ -0,0 +1,6 @@ +--- +"@primer/react": minor +--- + +Link components no longer accept an `as` prop. If you need link-like styling, you should use a different component and style accordingly. +Button has a `link` variant which can be used for this purpose. diff --git a/docs/content/Link.mdx b/docs/content/Link.mdx index b414769cc89..3882a7cd795 100644 --- a/docs/content/Link.mdx +++ b/docs/content/Link.mdx @@ -10,10 +10,6 @@ import data from '../../src/Link/Link.docs.json' The Link component styles anchor tags with default hyperlink color cues and hover text decoration. `Link` is used for destinations, or moving from one page to another. -In special cases where you'd like a `