Skip to content

Commit 6f4e347

Browse files
committed
fix: overflowY = 'auto' when set scroll.y
1 parent f921fdb commit 6f4e347

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

src/Table.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
317317

318318
if (fixHeader) {
319319
scrollYStyle = {
320-
overflowY: 'scroll',
320+
overflowY: 'auto',
321321
maxHeight: scroll.y,
322322
};
323323
}

tests/Scroll.spec.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import React from 'react';
21
import { mount } from 'enzyme';
3-
import { act } from 'react-dom/test-utils';
42
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
3+
import React from 'react';
4+
import { act } from 'react-dom/test-utils';
55
import Table from '../src';
66

77
describe('Table.Scroll', () => {
8-
const data = [{ key: 'key0', name: 'Lucy' }, { key: 'key1', name: 'Jack' }];
8+
const data = [
9+
{ key: 'key0', name: 'Lucy' },
10+
{ key: 'key1', name: 'Jack' },
11+
];
912
const createTable = props => {
1013
const columns = [{ title: 'Name', dataIndex: 'name', key: 'name' }];
1114

@@ -32,7 +35,7 @@ describe('Table.Scroll', () => {
3235
it('renders scroll.x and scroll.y are both true', () => {
3336
const wrapper = mount(createTable({ scroll: { x: true, y: 200 } }));
3437
expect(wrapper.find('.rc-table-body').props().style.overflowX).toEqual('auto');
35-
expect(wrapper.find('.rc-table-body').props().style.overflowY).toEqual('scroll');
38+
expect(wrapper.find('.rc-table-body').props().style.overflowY).toEqual('auto');
3639
});
3740

3841
it('fire scroll event', () => {

tests/__snapshots__/FixedColumn.spec.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1957,7 +1957,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
19571957
</div>
19581958
<div
19591959
class="rc-table-body"
1960-
style="overflow-x: auto; overflow-y: scroll; max-height: 100px;"
1960+
style="overflow-x: auto; overflow-y: auto; max-height: 100px;"
19611961
>
19621962
<table
19631963
style="width: 1200px; min-width: 100%; table-layout: fixed;"
@@ -2800,7 +2800,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - without data 1`] = `
28002800
</div>
28012801
<div
28022802
class="rc-table-body"
2803-
style="overflow-x: auto; overflow-y: scroll; max-height: 100px;"
2803+
style="overflow-x: auto; overflow-y: auto; max-height: 100px;"
28042804
>
28052805
<table
28062806
style="width: 1200px; min-width: 100%; table-layout: fixed;"

tests/__snapshots__/Table.spec.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ exports[`Table.Basic custom components renders fixed column and header correctly
199199
</div>
200200
<div
201201
class="rc-table-body"
202-
style="overflow-x: auto; overflow-y: scroll; max-height: 100px;"
202+
style="overflow-x: auto; overflow-y: auto; max-height: 100px;"
203203
>
204204
<table
205205
name="my-table"

0 commit comments

Comments
 (0)