From 8f3cb457e82780beda33d3c57cd9a69f4d429049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E5=BB=B7=E5=AE=89?= <73953029+nrps9909@users.noreply.github.com> Date: Fri, 28 Aug 2026 17:53:50 +0800 Subject: [PATCH] fix: default missing horizontal offset --- src/Filler.tsx | 2 +- tests/filler.test.tsx | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/filler.test.tsx 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', + }); + }); +});