Skip to content

Commit

Permalink
fix(createTearsheet): resolve focus out issue
Browse files Browse the repository at this point in the history
  • Loading branch information
makafsal committed Nov 27, 2024
1 parent cd33f92 commit 0e02913
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ export let CreateTearsheet = forwardRef(
verticalPosition,
closeIconDescription: '',
}}
currentStep={currentStep}
>
<div className={`${blockClass}__content`} ref={contentRef}>
<Form aria-label={title}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ interface TearsheetShellProps extends PropsWithChildren {
*/
className?: string;

/**
* Used to track the current step on components which use `StepsContext` and `TearsheetShell`
*/
currentStep?: number;

/**
* A description of the flow, displayed in the header area of the tearsheet.
*/
Expand Down Expand Up @@ -238,6 +243,7 @@ export const TearsheetShell = React.forwardRef(
children,
className,
closeIconDescription,
currentStep,
description,
hasCloseIcon,
headerActions,
Expand Down Expand Up @@ -307,16 +313,12 @@ export const TearsheetShell = React.forwardRef(
}

useEffect(() => {
if (
open &&
position === depth &&
modalRef &&
!modalRef?.current.contains(document.activeElement)
) {
if (open && position === depth) {
// Focusing the first element or selectorPrimaryFocus element
claimFocus(firstElement, modalRef, selectorPrimaryFocus);
}
}, [
currentStep,
depth,
firstElement,
modalRef,
Expand Down

0 comments on commit 0e02913

Please sign in to comment.