- {normalizedSlug}
+ {/* aiLabel and close */}
+
+ {normalizedAILabel}
labelText),
+
+ ...deprecatedProps,
};
SidePanel.displayName = componentName;
diff --git a/packages/ibm-products/src/components/Tearsheet/TearsheetShell.tsx b/packages/ibm-products/src/components/Tearsheet/TearsheetShell.tsx
index 4bd8e48769..e426b42902 100644
--- a/packages/ibm-products/src/components/Tearsheet/TearsheetShell.tsx
+++ b/packages/ibm-products/src/components/Tearsheet/TearsheetShell.tsx
@@ -346,15 +346,27 @@ export const TearsheetShell = React.forwardRef(
useEffect(() => {
if (open) {
// Focusing the first element or selectorPrimaryFocus element
- setTimeout(() => {
- if (selectorPrimaryFocus) {
- return specifiedElement?.focus();
+ if (
+ selectorPrimaryFocus &&
+ getSpecificElement(modalRef?.current, selectorPrimaryFocus)
+ ) {
+ const specifiedEl = getSpecificElement(
+ modalRef?.current,
+ selectorPrimaryFocus
+ );
+
+ if (
+ specifiedEl &&
+ window?.getComputedStyle(specifiedEl)?.display !== 'none'
+ ) {
+ setTimeout(() => specifiedEl.focus(), 0);
+ return;
}
- firstElement?.focus();
- }, 0);
+ }
+
+ setTimeout(() => firstElement?.focus(), 0);
}
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [open]);
+ }, [firstElement, modalRef, open, selectorPrimaryFocus]);
useEffect(() => {
if (prevOpen && !open && launcherButtonRef) {