Skip to content

Commit 4d45358

Browse files
authored
feat(SelectDialog): add headerTextLevel prop (#7595)
Closes #7593 Related to: #7568
1 parent b36f1fa commit 4d45358

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/main/src/components/SelectDialog/SelectDialog.cy.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@ describe('SelectDialog', () => {
2727
);
2828
cy.findByText('Select Dialog')
2929
.should('have.css', 'grid-column-start', 'titleStart')
30-
.should('have.css', 'grid-column-end', 'titleCenter');
30+
.and('have.css', 'grid-column-end', 'titleCenter')
31+
.and('have.attr', 'level', 'H1');
3132
cy.mount(
3233
<SelectDialog headerText="Select Dialog" headerTextAlignCenter open>
3334
{listItems}
3435
</SelectDialog>,
3536
);
36-
cy.findByText('Select Dialog').should('have.css', 'grid-area', 'titleCenter');
37+
cy.findByText('Select Dialog').should('have.css', 'grid-area', 'titleCenter').and('have.attr', 'level', 'H1');
38+
cy.mount(
39+
<SelectDialog headerText="Select Dialog" open headerTextLevel={'H2'}>
40+
{listItems}
41+
</SelectDialog>,
42+
);
43+
cy.findByText('Select Dialog').should('have.attr', 'level', 'H2');
3744
});
3845

3946
it('selection', () => {

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ export interface SelectDialogPropTypes
6565
* Specifies the `headerText` alignment.
6666
*/
6767
headerTextAlignCenter?: boolean;
68+
/**
69+
* Defines the aria-level of the `headerText`.
70+
* Available options are: `"H1"` to `"H6"`.
71+
* This property does not influence the style of the `headerText`.
72+
*
73+
* @default "H1"
74+
*/
75+
headerTextLevel?: TitleLevel | keyof typeof TitleLevel;
6876
/**
6977
* Overwrites the default text for the confirmation button.
7078
*/
@@ -150,6 +158,7 @@ const SelectDialog = forwardRef<DialogDomRef, SelectDialogPropTypes>((props, ref
150158
growing,
151159
headerText,
152160
headerTextAlignCenter,
161+
headerTextLevel = TitleLevel.H1,
153162
listProps = {},
154163
selectionMode = ListSelectionMode.Single,
155164
numberOfSelectedItems,
@@ -309,7 +318,7 @@ const SelectDialog = forwardRef<DialogDomRef, SelectDialogPropTypes>((props, ref
309318
)}
310319
<Title
311320
className={clsx(classNames.title, headerTextAlignCenter && classNames.titleCenterAlign)}
312-
level={TitleLevel.H1}
321+
level={headerTextLevel}
313322
>
314323
{headerText}
315324
</Title>

0 commit comments

Comments
 (0)