Commit 24987f8d authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Apply applyFocusVisiblePolyfill to shadow DOM elements

Follow instructions from: https://github.com/WICG/focus-visible#shadow-dom

Closes #2959 #2689
parent 0fc03e41
...@@ -9,17 +9,19 @@ const noop = () => {}; ...@@ -9,17 +9,19 @@ const noop = () => {};
describe('Toolbar', () => { describe('Toolbar', () => {
const createToolbar = props => const createToolbar = props =>
mount( mount(
<Toolbar <div>
closeSidebar={noop} <Toolbar
createAnnotation={noop} closeSidebar={noop}
toggleHighlights={noop} createAnnotation={noop}
toggleSidebar={noop} toggleHighlights={noop}
isSidebarOpen={false} toggleSidebar={noop}
showHighlights={false} isSidebarOpen={false}
newAnnotationType="note" showHighlights={false}
useMinimalControls={false} newAnnotationType="note"
{...props} useMinimalControls={false}
/> {...props}
/>
</div>
); );
const findButton = (wrapper, label) => const findButton = (wrapper, label) =>
......
...@@ -98,7 +98,7 @@ export default function Toolbar({ ...@@ -98,7 +98,7 @@ export default function Toolbar({
useMinimalControls = false, useMinimalControls = false,
}) { }) {
return ( return (
<div> <>
{useMinimalControls && isSidebarOpen && ( {useMinimalControls && isSidebarOpen && (
<ToolbarButton <ToolbarButton
className="annotator-toolbar__sidebar-close" className="annotator-toolbar__sidebar-close"
...@@ -134,7 +134,7 @@ export default function Toolbar({ ...@@ -134,7 +134,7 @@ export default function Toolbar({
/> />
</div> </div>
)} )}
</div> </>
); );
} }
......
...@@ -47,6 +47,7 @@ export function createShadowRoot(container) { ...@@ -47,6 +47,7 @@ export function createShadowRoot(container) {
loadStyles(shadowRoot); loadStyles(shadowRoot);
// @ts-ignore The window doesn't know about the polyfill // @ts-ignore The window doesn't know about the polyfill
// applyFocusVisiblePolyfill comes from the `focus-visible` package.
const applyFocusVisible = window.applyFocusVisiblePolyfill; const applyFocusVisible = window.applyFocusVisiblePolyfill;
if (applyFocusVisible) { if (applyFocusVisible) {
applyFocusVisible(shadowRoot); applyFocusVisible(shadowRoot);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment