diff --git a/src/app/components/Dropdown.tsx b/src/app/components/Dropdown.tsx
index a2f009e0f7..de52e7a683 100644
--- a/src/app/components/Dropdown.tsx
+++ b/src/app/components/Dropdown.tsx
@@ -1,3 +1,4 @@
+
import { HTMLElement } from '@openstax/types/lib.dom';
import flow from 'lodash/fp/flow';
import isUndefined from 'lodash/fp/isUndefined';
@@ -5,9 +6,9 @@ import omitBy from 'lodash/fp/omitBy';
import React, { ReactNode } from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import styled, { css, keyframes } from 'styled-components/macro';
-import { useFocusLost } from '../reactUtils';
+import { useFocusLost, useTrapTabNavigation } from '../reactUtils';
import { useOnEsc } from '../reactUtils';
-import theme from '../theme';
+import theme, { defaultFocusOutline } from '../theme';
import { preventDefault } from '../utils';
import { textStyle } from './Typography/base';
@@ -165,8 +166,19 @@ const TabTransparentDropdown = styled((
`}
`;
+function TrappingDropdownList(props: object) {
+ const ref = React.useRef(null);
+
+ useTrapTabNavigation(ref);
+
+ return (
+
+ );
+}
+
+
// tslint:disable-next-line:variable-name
-export const DropdownList = styled.ol`
+export const DropdownList = styled(TrappingDropdownList)`
margin: 0;
padding: 0.6rem 0;
background: ${theme.color.neutral.formBackground};
@@ -198,12 +210,12 @@ export const DropdownList = styled.ol`
&:hover,
&:focus {
background: ${theme.color.neutral.formBorder};
- outline: 0.2rem auto Highlight;
- outline: 0.2rem inset -webkit-focus-ring-color;
+ ${defaultFocusOutline}
}
}
`;
+
interface DropdownItemProps {
message: string;
ariaMessage?: string;
diff --git a/src/app/components/__snapshots__/DotMenu.spec.tsx.snap b/src/app/components/__snapshots__/DotMenu.spec.tsx.snap
index 80acb6703f..b3fb1c0479 100644
--- a/src/app/components/__snapshots__/DotMenu.spec.tsx.snap
+++ b/src/app/components/__snapshots__/DotMenu.spec.tsx.snap
@@ -179,7 +179,7 @@ exports[`Dropdown matches snapshot 1`] = `
.c12 li a:focus {
background: #d5d5d5;
outline: 0.2rem auto Highlight;
- outline: 0.2rem inset -webkit-focus-ring-color;
+ outline: 0.2rem auto -webkit-focus-ring-color;
}
.c12.c12 {
@@ -452,7 +452,7 @@ exports[`Dropdown matches snapshot on right align 1`] = `
.c12 li a:focus {
background: #d5d5d5;
outline: 0.2rem auto Highlight;
- outline: 0.2rem inset -webkit-focus-ring-color;
+ outline: 0.2rem auto -webkit-focus-ring-color;
}
.c12.c12 {
@@ -499,6 +499,7 @@ exports[`Dropdown matches snapshot on right align 1`] = `
-
-
+
-
+
+
-
-
+ title="pink"
+ >
+
+
+
+
+
+
+
-
diff --git a/src/app/content/highlights/components/SummaryPopup/__snapshots__/Filters.spec.tsx.snap b/src/app/content/highlights/components/SummaryPopup/__snapshots__/Filters.spec.tsx.snap
index e4abcf53f0..82feefd4e1 100644
--- a/src/app/content/highlights/components/SummaryPopup/__snapshots__/Filters.spec.tsx.snap
+++ b/src/app/content/highlights/components/SummaryPopup/__snapshots__/Filters.spec.tsx.snap
@@ -69,8 +69,8 @@ input:checked + .c21 .c22 {
.c19:focus-within {
border-radius: 0.4rem;
background-color: #f1f1f1;
- outline: 0.1rem dotted #212121;
- outline: 0.5rem auto -webkit-focus-ring-color;
+ outline: 0.2rem auto Highlight;
+ outline: 0.2rem auto -webkit-focus-ring-color;
}
.c19:focus-within .c20 {
@@ -277,8 +277,9 @@ input:checked + .c21 .c22 {
.c25 input:focus + .c28 {
display: block;
- outline: 0.1rem dotted #212121;
- outline: 0.5rem auto -webkit-focus-ring-color;
+ outline: 0.2rem auto Highlight;
+ outline: 0.2rem auto -webkit-focus-ring-color;
+ z-index: 1;
}
.c32 {
@@ -310,8 +311,9 @@ input:checked + .c21 .c22 {
.c32 input:focus + .c28 {
display: block;
- outline: 0.1rem dotted #212121;
- outline: 0.5rem auto -webkit-focus-ring-color;
+ outline: 0.2rem auto Highlight;
+ outline: 0.2rem auto -webkit-focus-ring-color;
+ z-index: 1;
}
.c34 {
@@ -343,8 +345,9 @@ input:checked + .c21 .c22 {
.c34 input:focus + .c28 {
display: block;
- outline: 0.1rem dotted #212121;
- outline: 0.5rem auto -webkit-focus-ring-color;
+ outline: 0.2rem auto Highlight;
+ outline: 0.2rem auto -webkit-focus-ring-color;
+ z-index: 1;
}
.c36 {
@@ -376,8 +379,9 @@ input:checked + .c21 .c22 {
.c36 input:focus + .c28 {
display: block;
- outline: 0.1rem dotted #212121;
- outline: 0.5rem auto -webkit-focus-ring-color;
+ outline: 0.2rem auto Highlight;
+ outline: 0.2rem auto -webkit-focus-ring-color;
+ z-index: 1;
}
.c38 {
@@ -409,8 +413,9 @@ input:checked + .c21 .c22 {
.c38 input:focus + .c28 {
display: block;
- outline: 0.1rem dotted #212121;
- outline: 0.5rem auto -webkit-focus-ring-color;
+ outline: 0.2rem auto Highlight;
+ outline: 0.2rem auto -webkit-focus-ring-color;
+ z-index: 1;
}
.c48 {
diff --git a/src/app/content/highlights/components/__snapshots__/ColorIndicator.spec.tsx.snap b/src/app/content/highlights/components/__snapshots__/ColorIndicator.spec.tsx.snap
index 889e6d0971..153b507ca6 100644
--- a/src/app/content/highlights/components/__snapshots__/ColorIndicator.spec.tsx.snap
+++ b/src/app/content/highlights/components/__snapshots__/ColorIndicator.spec.tsx.snap
@@ -47,8 +47,9 @@ exports[`ColorIndicator matches snapshot (checked) 1`] = `
.c7 input:focus + .c4 {
display: block;
- outline: 0.1rem dotted #212121;
- outline: 0.5rem auto -webkit-focus-ring-color;
+ outline: 0.2rem auto Highlight;
+ outline: 0.2rem auto -webkit-focus-ring-color;
+ z-index: 1;
}
.c0 {
@@ -84,8 +85,9 @@ exports[`ColorIndicator matches snapshot (checked) 1`] = `
.c0 input:focus + .c4 {
display: block;
- outline: 0.1rem dotted #212121;
- outline: 0.5rem auto -webkit-focus-ring-color;
+ outline: 0.2rem auto Highlight;
+ outline: 0.2rem auto -webkit-focus-ring-color;
+ z-index: 1;
}
{
}
}, [archiveLoader, osWebLoader]);
- const renderBookLink = (id: string, book: Book | undefined) => {
+ function BookLink({id, book}: {id: string, book: Book | undefined}) {
const page = book && findDefaultBookPage(book);
+
return <>
{book && page
@@ -75,12 +76,12 @@ const Books = () => {
: null
}
>;
- };
+ }
return
{books.map(([id, config, book]) =>
- {renderBookLink(`${id}@${config.defaultVersion}`, book)}
+
)}
;
diff --git a/src/app/theme.ts b/src/app/theme.ts
index 141ca5ffe8..a53b137f7e 100644
--- a/src/app/theme.ts
+++ b/src/app/theme.ts
@@ -30,10 +30,10 @@ const textColors = {
// Browser default outline for focus items per
// tslint:disable-next-line:max-line-length
-// https://stackoverflow.com/questions/20609485/what-is-the-default-style-of-the-blue-focus-outline-in-chrome/38498539#38498539
+// https://css-tricks.com/copy-the-browsers-native-focus-styles/
export const defaultFocusOutline = `
- outline: 0.1rem dotted #212121;
- outline: 0.5rem auto -webkit-focus-ring-color;
+ outline: 0.2rem auto Highlight;
+ outline: 0.2rem auto -webkit-focus-ring-color;
`;
const greyColors = {