diff --git a/src/Filler.tsx b/src/Filler.tsx index c397898..f3c2de4 100644 --- a/src/Filler.tsx +++ b/src/Filler.tsx @@ -61,7 +61,7 @@ const Filler = React.forwardRef( innerStyle = { ...innerStyle, transform: `translateY(${offsetY}px)`, - [rtl ? 'marginRight' : 'marginLeft']: -offsetX, + [rtl ? 'marginRight' : 'marginLeft']: -offsetX || 0, position: 'absolute', left: 0, right: 0, diff --git a/tests/filler.test.tsx b/tests/filler.test.tsx new file mode 100644 index 0000000..d2454d9 --- /dev/null +++ b/tests/filler.test.tsx @@ -0,0 +1,20 @@ +import { render } from '@testing-library/react'; +import React from 'react'; +import Filler from '../src/Filler'; + +describe('Filler', () => { + it.each([ + [false, 'marginLeft'], + [true, 'marginRight'], + ] as const)('defaults an omitted horizontal offset in RTL %s', (rtl, marginProperty) => { + const { container } = render( + +
item
+
, + ); + + expect(container.firstElementChild?.firstElementChild).toHaveStyle({ + [marginProperty]: '0px', + }); + }); +});