Skip to content

Commit f6d2228

Browse files
committed
fix(ObjectPage): announce first section heading with screen readers
1 parent a0f234d commit f6d2228

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

packages/main/src/components/ObjectPage/ObjectPage.module.css

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121
&[data-in-iframe='true'] {
2222
scroll-behavior: auto;
2323
}
24-
section[id*='ObjectPageSection-'] > div[role='heading'] {
25-
display: none;
26-
}
2724

28-
/* explanation why first-child selector is not sufficient here:
29-
https://stackoverflow.com/questions/7128406/css-select-the-first-child-from-elements-with-particular-attribute
30-
*/
31-
section[id*='ObjectPageSection-'] ~ section[id*='ObjectPageSection-'] > div[role='heading'] {
32-
display: block;
25+
/*invisible first heading*/
26+
section[id*='ObjectPageSection-']:first-of-type > div[role='heading'] {
27+
position: absolute;
28+
width: 1px;
29+
height: 1px;
30+
padding: 0;
31+
margin: -1px;
32+
overflow: hidden;
33+
clip: rect(0, 0, 0, 0);
34+
border: 0;
35+
white-space: nowrap;
3336
}
3437
}
3538

packages/main/src/components/ObjectPage/ObjectPage.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const meta = {
7272
),
7373
titleArea: (
7474
<ObjectPageTitle
75-
header="Denise Smith"
75+
header={<Title level="H2">Denise Smith</Title>}
7676
subHeader="Senior UI Developer"
7777
actionsBar={
7878
<Toolbar design="Transparent">

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ export interface ObjectPageTitlePropTypes extends CommonProps {
3333

3434
/**
3535
* The `header` is positioned in the `ObjectPageTitle` left area.
36+
*
3637
* Use this prop to display a `Title` (or any other component that serves as a heading).
3738
*/
3839
header?: ReactNode;
3940
/**
4041
* The `subHeader` is positioned in the `ObjectPageTitle` left area below the `header`.
42+
*
4143
* Use this aggregation to display a component like `Label` or any other component that serves as sub header.
4244
*/
4345
subHeader?: ReactNode;
@@ -225,7 +227,7 @@ const ObjectPageTitle = forwardRef<HTMLDivElement, ObjectPageTitlePropTypes>((pr
225227
>
226228
<FlexBox className={classNames.titleMainSection} onClick={onHeaderClick}>
227229
{header && (
228-
<div className={classNames.title} data-component-name="ObjectPageTitleHeader" /*onClick={onHeaderClick}*/>
230+
<div className={classNames.title} data-component-name="ObjectPageTitleHeader">
229231
{header}
230232
</div>
231233
)}

0 commit comments

Comments
 (0)