Skip to content

Commit a39b56b

Browse files
committed
handle edge-cases
1 parent 8f2e1e7 commit a39b56b

File tree

1 file changed

+10
-1
lines changed
  • packages/main/src/components/ObjectPageSection

1 file changed

+10
-1
lines changed

packages/main/src/components/ObjectPageSection/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ const ObjectPageSection = forwardRef<HTMLElement, ObjectPageSectionPropTypes>((p
8282
if (typeof props.onFocus === 'function') {
8383
props.onFocus(e);
8484
}
85+
// reset tab-index of all sections, so only the focused one is tabbable
86+
Array.from(e.currentTarget.parentElement.children as HTMLCollectionOf<HTMLElement>).forEach((el) => {
87+
if (el.dataset.componentName === 'ObjectPageSection') {
88+
el.tabIndex = -1;
89+
}
90+
});
91+
e.currentTarget.tabIndex = 0;
8592
const hasSubSection = Children.toArray(children).some(
8693
// @ts-expect-error: if type is string, then it's not a subcomponent
8794
(child) => isValidElement(child) && child.type?.displayName === 'ObjectPageSubSection',
@@ -127,7 +134,9 @@ const ObjectPageSection = forwardRef<HTMLElement, ObjectPageSectionPropTypes>((p
127134
(target.previousElementSibling as HTMLElement).dataset.componentName !== 'ObjectPageSection';
128135
// header collapse leads to loose scrolling - this fallback makes sure the second section is marked as selected
129136
if (isFirstSection) {
130-
target.parentElement.parentElement.scrollBy(0, 14);
137+
setTimeout(() => {
138+
target.parentElement.parentElement.scrollBy(0, 14);
139+
});
131140
}
132141
});
133142
}

0 commit comments

Comments
 (0)