Skip to content

Commit e2c1aea

Browse files
刘欢claude
andcommitted
test: add test for nearest align with element above viewport
Adds test coverage for the scrollTo nearest alignment when the target element is above the current viewport after applying offset. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ec47eb8 commit e2c1aea

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/refs.spec.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,28 @@ describe('Table.Ref', () => {
184184
ref.current.scrollTo({ index: 0, align: 'nearest', offset: 50 });
185185
expect(scrollParam.top).toEqual(50);
186186
});
187+
188+
it('support scrollTo with align nearest and element above viewport', () => {
189+
const ref = React.createRef<Reference>();
190+
191+
render(
192+
<Table
193+
data={[{ key: 'light' }, { key: 'bamboo' }]}
194+
columns={[
195+
{
196+
dataIndex: 'key',
197+
},
198+
]}
199+
ref={ref}
200+
scroll={{
201+
y: 100,
202+
}}
203+
/>,
204+
);
205+
206+
ref.current.scrollTo({ top: 50 });
207+
208+
ref.current.scrollTo({ index: 0, align: 'nearest', offset: -10 });
209+
expect(scrollParam.top).toEqual(-10);
210+
});
187211
});

0 commit comments

Comments
 (0)