Skip to content

Commit

Permalink
fix: fixed VO and JAWS problem in FF and Safari (#14156)
Browse files Browse the repository at this point in the history
* fix: fixed VO and JAWS problem in FF and Safari

* fix: removed aria hidden

* fix: removed tabIndex from focus sentinel

* fix: remove wrong tabIndex

* fix(composedmodal): improve initial focus to match modal behavior

* Update Modal.js

Remove the tabIndex from Modal

* fix: added button inside the dialog

---------

Co-authored-by: Taylor Jones <taylor.jones826@gmail.com>
  • Loading branch information
guidari and tay1orjones authored Jul 13, 2023
1 parent f20a3a4 commit ef1336a
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions packages/react/src/components/ComposedModal/ComposedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,28 +305,30 @@ const ComposedModal = React.forwardRef<HTMLDivElement, ComposedModalProps>(
});

useEffect(() => {
const focusButton = (focusContainerElement) => {
if (focusContainerElement) {
const primaryFocusElement =
focusContainerElement.querySelector(selectorPrimaryFocus);
if (primaryFocusElement) {
primaryFocusElement.focus();
return;
}
if (button.current) {
button.current.focus();
}
const initialFocus = (focusContainerElement) => {
const containerElement = focusContainerElement || innerModal.current;
const primaryFocusElement = containerElement
? containerElement.querySelector(selectorPrimaryFocus)
: null;

if (primaryFocusElement) {
return primaryFocusElement;
}

return button && button.current;
};

if (!open) {
return;
}
const focusButton = (focusContainerElement) => {
const target = initialFocus(focusContainerElement);
if (target) {
target.focus();
}
};

if (innerModal.current) {
if (open && isOpen) {
focusButton(innerModal.current);
}
}, [open, selectorPrimaryFocus]);
}, [open, selectorPrimaryFocus, isOpen]);

return (
<div
Expand All @@ -345,6 +347,7 @@ const ComposedModal = React.forwardRef<HTMLDivElement, ComposedModalProps>(
aria-label={ariaLabel ? ariaLabel : generatedAriaLabel}
aria-labelledby={ariaLabelledBy}>
{/* Non-translatable: Focus-wrap code makes this `<button>` not actually read by screen readers */}

<button
type="button"
ref={startSentinel}
Expand Down

0 comments on commit ef1336a

Please sign in to comment.