|
3 | 3 | import type TitleLevel from '@ui5/webcomponents/dist/types/TitleLevel.js'; |
4 | 4 | import { useStylesheet, useSyncRef } from '@ui5/webcomponents-react-base'; |
5 | 5 | import { clsx } from 'clsx'; |
6 | | -import type { ReactNode, FocusEventHandler, KeyboardEventHandler, FocusEvent } from 'react'; |
| 6 | +import type { ReactNode, FocusEventHandler, KeyboardEventHandler, FocusEvent, Ref } from 'react'; |
7 | 7 | import { Children, isValidElement, forwardRef, useMemo } from 'react'; |
8 | 8 | import { ObjectPageMode } from '../../enums/ObjectPageMode.js'; |
9 | 9 | import type { CommonProps } from '../../types/index.js'; |
| 10 | +import type { TabDomRef } from '../../webComponents/Tab/index.js'; |
10 | 11 | import { useObjectPageContext } from '../ObjectPage/context.js'; |
11 | 12 | import { navigateSections } from '../ObjectPage/ObjectPageUtils.js'; |
12 | 13 | import { classNames, styleData } from './ObjectPageSection.module.css.js'; |
@@ -57,6 +58,12 @@ export interface ObjectPageSectionPropTypes extends CommonProps { |
57 | 58 | * __Note__: Although this prop accepts all HTML Elements, it is strongly recommended that you only use non-focusable elements to preserve the intended design. |
58 | 59 | */ |
59 | 60 | header?: ReactNode; |
| 61 | + // the ref is applied in the ObjectPage |
| 62 | + /** |
| 63 | + * This ref will be attached to the underlying `ui5-tab` DOM element, |
| 64 | + * allowing direct access to its instance methods and properties (e.g. `getDomRefInStrip`). |
| 65 | + */ |
| 66 | + tabRef?: Ref<TabDomRef>; |
60 | 67 | } |
61 | 68 |
|
62 | 69 | function recursiveSetTabIndexOnSubSection(el: HTMLElement | null, currentTarget: HTMLElement): void { |
@@ -121,6 +128,9 @@ const ObjectPageSection = forwardRef<HTMLElement, ObjectPageSectionPropTypes>((p |
121 | 128 | header, |
122 | 129 | ...rest |
123 | 130 | } = props; |
| 131 | + |
| 132 | + const { tabRef: _0, ...propsWithoutOmitted } = rest; |
| 133 | + |
124 | 134 | useStylesheet(styleData, ObjectPageSection.displayName); |
125 | 135 | const [componentRef, sectionRef] = useSyncRef(ref); |
126 | 136 | const htmlId = `ObjectPageSection-${id}`; |
@@ -227,7 +237,7 @@ const ObjectPageSection = forwardRef<HTMLElement, ObjectPageSectionPropTypes>((p |
227 | 237 | className={clsx(classNames.section, wrapTitleText && classNames.wrap, className)} |
228 | 238 | style={style} |
229 | 239 | tabIndex={objectPageMode === ObjectPageMode.Default ? -1 : 0} |
230 | | - {...rest} |
| 240 | + {...propsWithoutOmitted} |
231 | 241 | id={htmlId} |
232 | 242 | data-component-name="ObjectPageSection" |
233 | 243 | onFocus={objectPageMode === ObjectPageMode.Default ? handleFocusDefault : handleFocusIconTabBar} |
|
0 commit comments