Skip to content

Commit d75db57

Browse files
authored
Merge pull request #24 from Zloka/support-htmldivelement-props
Add an optional `id` prop rootElement
2 parents 5e7083a + 66dabad commit d75db57

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

docs/API.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ order: 4
1818
| className | className for the root component | `string` | `undefined`
1919
| disableDefaultStyles | removes basic styling to ease visual customization | `boolean` | `false`
2020
| hideTracksWhenNotNeeded | Hide tracks (`visibility: hidden`) when content does not overflow container. | `boolean` | `false` |
21+
| id | The `id` to apply to the root element | `string` | `undefined` |
2122
| onScroll | Event handler | `(e: React.UIEvent<HTMLElement>) => void` | `undefined` |
2223
| onScrollFrame | Runs inside the animation frame. Type of `ScrollValues` you can check below | `(values: ScrollValues) => void` | `undefined` |
2324
| onScrollStart | Called when scrolling starts | `() => void` | `undefined` |

src/Scrollbars/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface ScrollbarsProps {
1313
classes?: Partial<StyleClasses>;
1414
disableDefaultStyles: boolean;
1515
hideTracksWhenNotNeeded?: boolean;
16+
id?: string;
1617
onScroll?: (e: React.UIEvent<HTMLElement>) => void;
1718
onScrollFrame?: (values: ScrollValues) => void;
1819
onScrollStart?: () => void;

test/Scrollbars/rendering.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ export default function createTests(scrollbarWidth) {
2727
);
2828
});
2929

30+
it('takes id', (done) => {
31+
render(
32+
<Scrollbars id="foo">
33+
<div style={{ width: 200, height: 200 }} />
34+
</Scrollbars>,
35+
node,
36+
function callback() {
37+
expect(findDOMNode(this).id).toEqual('foo');
38+
done();
39+
},
40+
);
41+
});
42+
3043
it('takes styles', (done) => {
3144
render(
3245
<Scrollbars style={{ width: 100, height: 100 }}>

0 commit comments

Comments
 (0)