Skip to content

Commit

Permalink
feat(table-of-contents): add data-test attribute (#161)
Browse files Browse the repository at this point in the history
* feat(table-of-contents): add data-test attribute

* fix(table-of-contents): make prop optional
  • Loading branch information
Marcell Toth authored May 19, 2020
1 parent 3137d31 commit dc350cc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/TableOfContents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export interface ITableOfContents<T extends TableOfContentsItem = TableOfContent
padding?: string;
className?: string;

/**
* HTML data-test attribute to be set on the container div.
*/
'data-test'?: string;

// force items to render with active or selected if either is true.
// for example if forceStateStyle=active, then if an item isSelected or isActive is true, will render with active styling
forceStateStyle?: 'active' | 'selected';
Expand Down Expand Up @@ -167,6 +172,7 @@ function TableOfContentsInner<T extends TableOfContentsItem = TableOfContentsIte

export function TableOfContents<T extends TableOfContentsItem = TableOfContentsItem>({
className,
'data-test': dataTest,
padding = '4',
title,
isOpen = false,
Expand Down Expand Up @@ -198,7 +204,7 @@ export function TableOfContents<T extends TableOfContentsItem = TableOfContentsI
/>
)}

<div className={containerClassName}>
<div className={containerClassName} data-test={dataTest}>
{renderWithScroll && withScroller ? <ScrollContainer>{toc}</ScrollContainer> : toc}
</div>
</>
Expand Down

0 comments on commit dc350cc

Please sign in to comment.