Skip to content

Commit

Permalink
TPP-849 improve accessibility of popover (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
KitoC authored Aug 13, 2024
1 parent 784bc1d commit e7d7676
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
29 changes: 2 additions & 27 deletions lib/components/Popover/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { cloneElement, useEffect, useState } from "react";
import React, { cloneElement, useState } from "react";
import {
useFloating,
autoUpdate,
Expand Down Expand Up @@ -337,27 +337,6 @@ export default function Popover({
? direction
: context.placement;

useEffect(() => {
// Following code disables the tabbing of elements for popovers when it is not open.
const floatingEl = context?.refs?.floating?.current;

if (!floatingEl) return;

const childrenAnchors = Array.from(floatingEl.getElementsByTagName?.("a"));

if (!childrenAnchors.length) return;

if (visible) {
childrenAnchors.forEach((anchor) => {
anchor.tabIndex = "";
});
} else {
childrenAnchors.forEach((anchor) => {
anchor.tabIndex = "-1";
});
}
}, [visible, context]);

const Popover = (
<StyledPopover
textAlign={textAlign}
Expand Down Expand Up @@ -386,11 +365,7 @@ export default function Popover({
root={getFloatingUiRootElement(context.refs.reference)}
preserveTabOrder={true}
>
<FloatingFocusManager
initialFocus={context.refs?.reference}
context={context}
modal={false}
>
<FloatingFocusManager context={context} modal={false}>
{Popover}
</FloatingFocusManager>
</FloatingPortal>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orcs-design-system",
"version": "3.2.26",
"version": "3.2.27",
"engines": {
"node": "20.12.2"
},
Expand Down

0 comments on commit e7d7676

Please sign in to comment.