Skip to content

Commit

Permalink
Focus on DisplayNote goes to the menu button
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyEJohnson committed Sep 18, 2024
1 parent 9282bed commit 2f2d989
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/app/content/highlights/components/DisplayNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Dropdown, { DropdownItem, DropdownList } from '../../../components/Dropdo
import Times from '../../../components/Times';
import { textStyle } from '../../../components/Typography/base';
import { useDebouncedWindowSize, useFocusElement } from '../../../reactUtils';
import theme from '../../../theme';
import theme, { defaultFocusOutline } from '../../../theme';
import { mergeRefs } from '../../../utils';
import { highlightStyles } from '../../constants';
import { query } from '../../search/selectors';
Expand Down Expand Up @@ -92,13 +92,16 @@ const DisplayNote = React.forwardRef<HTMLElement, DisplayNoteProps>((
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [element, confirmationRef, confirmingDelete, textToggle, width, isTocOpen, searchQuery]);

useFocusElement(element, shouldFocusCard);
const buttonPseudoRef = {
current: element.current?.querySelector('button') ?? null
};

useFocusElement(buttonPseudoRef, shouldFocusCard);

return (
<div
className={className}
ref={mergeRefs(ref, element)}
tabIndex={-1}
data-highlight-card
role='dialog'
aria-label={formatMessage({id: 'i18n:highlighter:display-note:label'})}
Expand Down Expand Up @@ -164,6 +167,10 @@ export default styled(DisplayNote)`
:focus-within ${MenuIcon} {
color: ${theme.color.primary.gray.base};
}
> button:focus {
${defaultFocusOutline}
}
}
${theme.breakpoints.touchDeviceQuery(css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ exports[`DisplayNote matches snapshot 1`] = `
color: #5e6062;
}
.c0 .c2 > button:focus {
outline: 0.2rem auto Highlight;
outline: 0.2rem auto -webkit-focus-ring-color;
}
@media screen and (max-width:75em) {
.c0 {
margin-left: 8rem;
Expand All @@ -120,7 +125,6 @@ exports[`DisplayNote matches snapshot 1`] = `
className="c0"
data-highlight-card={true}
role="dialog"
tabIndex={-1}
>
<div
className="c1 c2 c3"
Expand Down Expand Up @@ -275,6 +279,11 @@ exports[`DisplayNote matches snapshot when focused 1`] = `
color: #5e6062;
}
.c12 .c2 > button:focus {
outline: 0.2rem auto Highlight;
outline: 0.2rem auto -webkit-focus-ring-color;
}
.c0 {
width: 20rem;
overflow: visible;
Expand Down Expand Up @@ -309,6 +318,11 @@ exports[`DisplayNote matches snapshot when focused 1`] = `
color: #5e6062;
}
.c0 .c2 > button:focus {
outline: 0.2rem auto Highlight;
outline: 0.2rem auto -webkit-focus-ring-color;
}
@media screen and (max-width:75em) {
.c0 {
margin-left: 8rem;
Expand All @@ -326,7 +340,6 @@ exports[`DisplayNote matches snapshot when focused 1`] = `
className="c0"
data-highlight-card={true}
role="dialog"
tabIndex={-1}
>
<div
className="c1 c2 c3"
Expand Down Expand Up @@ -531,6 +544,11 @@ exports[`DisplayNote matches snapshot when focused with opened dropdown 1`] = `
color: #5e6062;
}
.c14 .c2 > button:focus {
outline: 0.2rem auto Highlight;
outline: 0.2rem auto -webkit-focus-ring-color;
}
.c0 {
width: 20rem;
overflow: visible;
Expand Down Expand Up @@ -565,6 +583,11 @@ exports[`DisplayNote matches snapshot when focused with opened dropdown 1`] = `
color: #5e6062;
}
.c0 .c2 > button:focus {
outline: 0.2rem auto Highlight;
outline: 0.2rem auto -webkit-focus-ring-color;
}
@media screen and (max-width:75em) {
.c0 {
margin-left: 8rem;
Expand All @@ -582,7 +605,6 @@ exports[`DisplayNote matches snapshot when focused with opened dropdown 1`] = `
className="c0"
data-highlight-card={true}
role="dialog"
tabIndex={-1}
>
<div
className="c1 c2 c3"
Expand Down

0 comments on commit 2f2d989

Please sign in to comment.