Skip to content

Commit

Permalink
Hide tooltip trigger elements if JS is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
contolini committed Dec 3, 2024
1 parent 4f50825 commit eb584f8
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 43 deletions.
5 changes: 3 additions & 2 deletions docs/pages/tooltips.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ guidelines: Be judicious in using tooltips and explore other design options that
keep content visible before choosing to use a tooltip. Only consider using a
tooltip for short, non-critical information in a space-constrained user
interface. Because a tooltip is hidden until activated, ensure content within
a tooltip is not essential for completing a task on the page. For more
guidance, see the [USWDS tooltip
a tooltip is not essential for completing a task on the page. The tooltip
trigger element (usually a help icon) will be hidden for users with JavaScript
disabled. For more guidance, see the [USWDS tooltip
page](https://designsystem.digital.gov/components/tooltip/).
eyebrow: Components
behavior: >
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cfpb-design-system/dist/index.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/cfpb-design-system/dist/index.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cfpb-design-system/dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/cfpb-design-system/dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cfpb-design-system/dist/utilities/index.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/cfpb-design-system/dist/utilities/index.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cfpb-design-system/dist/utilities/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/cfpb-design-system/dist/utilities/index.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ function Tooltip(element) {
}
return {
onShow() {
document.addEventListener('keydown', onKeyDown);
document.body.addEventListener('keydown', onKeyDown);
},
onHide() {
document.removeEventListener('keydown', onKeyDown);
document.body.removeEventListener('keydown', onKeyDown);
},
};
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use 'sass:math';
@use '@cfpb/cfpb-design-system/src/abstracts' as *;
@import 'tippy.js/dist/tippy.css';
@import 'tippy.js/dist/border.css';
@use 'tippy.js/dist/tippy.css';
@use 'tippy.js/dist/border.css';

// Custom theme, see https://atomiks.github.io/tippyjs/v6/themes/
.tippy-box[data-theme='cfpb'] {
Expand All @@ -25,3 +25,8 @@
margin-top: math.div(15px, $base-font-size-px) + rem;
}
}

// Hide tooltip trigger elements when JS isn't supported
.no-js [data-tooltip] {
display: none;
}
14 changes: 8 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3453,9 +3453,10 @@ __metadata:
"@lhci/cli": "npm:0.14.0"
"@types/react": "npm:18.3.12"
anchor-js: "npm:5.0.0"
auto-changelog: "npm:2.5.0"
autoprefixer: "npm:10.4.20"
concurrently: "npm:9.0.1"
cypress: "npm:13.15.0"
cypress: "npm:13.15.1"
decap-cms-app: "npm:3.3.3"
esbuild: "npm:0.24.0"
esbuild-plugin-liquid: "npm:0.2.0"
Expand Down Expand Up @@ -4272,9 +4273,9 @@ __metadata:
languageName: node
linkType: hard

"cypress@npm:13.15.0":
version: 13.15.0
resolution: "cypress@npm:13.15.0"
"cypress@npm:13.15.1":
version: 13.15.1
resolution: "cypress@npm:13.15.1"
dependencies:
"@cypress/request": "npm:^3.0.4"
"@cypress/xvfb": "npm:^1.2.4"
Expand Down Expand Up @@ -4316,11 +4317,12 @@ __metadata:
semver: "npm:^7.5.3"
supports-color: "npm:^8.1.1"
tmp: "npm:~0.2.3"
tree-kill: "npm:1.2.2"
untildify: "npm:^4.0.0"
yauzl: "npm:^2.10.0"
bin:
cypress: bin/cypress
checksum: 10c0/d453c89f8220aecb726f842ea2895f452a4ec0c74f718834354533da62d28545eb68fc3ac21209df52d4314b4db4221d26ce8f33a6f08641eec3b4269f037717
checksum: 10c0/9deb474949cbd4c87e9b26a0b51c29f86f7c8ecdf865848f9e41bf7359f1887908856864b0fd722e4aa78e263fa4e0ff8bb5190495ff5f89fed89a6b3d38bb27
languageName: node
linkType: hard

Expand Down Expand Up @@ -13962,7 +13964,7 @@ __metadata:
languageName: node
linkType: hard

"tree-kill@npm:^1.2.1, tree-kill@npm:^1.2.2":
"tree-kill@npm:1.2.2, tree-kill@npm:^1.2.1, tree-kill@npm:^1.2.2":
version: 1.2.2
resolution: "tree-kill@npm:1.2.2"
bin:
Expand Down

0 comments on commit eb584f8

Please sign in to comment.