Skip to content

Commit 82a99ec

Browse files
committed
fix: default missing horizontal offset
1 parent 579a3bf commit 82a99ec

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/Filler.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const Filler = React.forwardRef(
6161
innerStyle = {
6262
...innerStyle,
6363
transform: `translateY(${offsetY}px)`,
64-
[rtl ? 'marginRight' : 'marginLeft']: -offsetX,
64+
[rtl ? 'marginRight' : 'marginLeft']: -(offsetX ?? 0),
6565
position: 'absolute',
6666
left: 0,
6767
right: 0,

tests/filler.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { render } from '@testing-library/react';
2+
import React from 'react';
3+
import Filler from '../src/Filler';
4+
5+
describe('Filler', () => {
6+
it.each([
7+
[false, 'marginLeft'],
8+
[true, 'marginRight'],
9+
] as const)('defaults an omitted horizontal offset in RTL %s', (rtl, marginProperty) => {
10+
const { container } = render(
11+
<Filler height={100} offsetY={0} rtl={rtl}>
12+
<div>item</div>
13+
</Filler>,
14+
);
15+
16+
expect(container.firstElementChild?.firstElementChild).toHaveStyle({
17+
[marginProperty]: '0px',
18+
});
19+
});
20+
});

0 commit comments

Comments
 (0)