Skip to content

Commit abdd395

Browse files
Antd #25124 hide horizontal scroll when no need (#495)
* 💄 antd-25124 hide horizontal scroll when no need to scroll * ✅ antd-25124 updating tests
1 parent c8564f3 commit abdd395

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/Table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
389389
}
390390

391391
if (horizonScroll) {
392-
scrollXStyle = { overflowX: 'scroll' };
392+
scrollXStyle = { overflowX: 'auto' };
393393
// When no vertical scrollbar, should hide it
394394
// https://github.com/ant-design/ant-design/pull/20705
395395
// https://github.com/ant-design/ant-design/issues/21879

tests/Scroll.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('Table.Scroll', () => {
1515
it('renders scroll.x is true', () => {
1616
const wrapper = mount(createTable({ scroll: { x: true } }));
1717
expect(wrapper.find('table').props().style.width).toEqual('auto');
18-
expect(wrapper.find('.rc-table-content').props().style.overflowX).toEqual('scroll');
18+
expect(wrapper.find('.rc-table-content').props().style.overflowX).toEqual('auto');
1919
expect(wrapper.find('.rc-table-content').props().style.overflowY).toEqual('hidden');
2020
});
2121

@@ -31,7 +31,7 @@ describe('Table.Scroll', () => {
3131

3232
it('renders scroll.x and scroll.y are both true', () => {
3333
const wrapper = mount(createTable({ scroll: { x: true, y: 200 } }));
34-
expect(wrapper.find('.rc-table-body').props().style.overflowX).toEqual('scroll');
34+
expect(wrapper.find('.rc-table-body').props().style.overflowX).toEqual('auto');
3535
expect(wrapper.find('.rc-table-body').props().style.overflowY).toEqual('scroll');
3636
});
3737

tests/__snapshots__/ExpandRow.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ exports[`Table.Expand renders fixed column correctly work 1`] = `
112112
>
113113
<div
114114
class="rc-table-content"
115-
style="overflow-x: scroll; overflow-y: hidden;"
115+
style="overflow-x: auto; overflow-y: hidden;"
116116
>
117117
<table
118118
style="width: 903px; min-width: 100%; table-layout: fixed;"

tests/__snapshots__/FixedColumn.spec.js.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exports[`Table.FixedColumn fixed column renders correctly RTL 1`] = `
99
>
1010
<div
1111
class="rc-table-content"
12-
style="overflow-x: scroll; overflow-y: hidden;"
12+
style="overflow-x: auto; overflow-y: hidden;"
1313
>
1414
<table
1515
style="width: 1px; min-width: 100%; table-layout: fixed;"
@@ -632,7 +632,7 @@ exports[`Table.FixedColumn renders correctly scrollX - with data 1`] = `
632632
>
633633
<div
634634
class="rc-table-content"
635-
style="overflow-x: scroll; overflow-y: hidden;"
635+
style="overflow-x: auto; overflow-y: hidden;"
636636
>
637637
<table
638638
style="width: 1200px; min-width: 100%; table-layout: fixed;"
@@ -1255,7 +1255,7 @@ exports[`Table.FixedColumn renders correctly scrollX - without data 1`] = `
12551255
>
12561256
<div
12571257
class="rc-table-content"
1258-
style="overflow-x: scroll; overflow-y: hidden;"
1258+
style="overflow-x: auto; overflow-y: hidden;"
12591259
>
12601260
<table
12611261
style="width: 1200px; min-width: 100%; table-layout: fixed;"
@@ -1526,7 +1526,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
15261526
</div>
15271527
<div
15281528
class="rc-table-body"
1529-
style="overflow-x: scroll; overflow-y: scroll; max-height: 100px;"
1529+
style="overflow-x: auto; overflow-y: scroll; max-height: 100px;"
15301530
>
15311531
<table
15321532
style="width: 1200px; min-width: 100%; table-layout: fixed;"
@@ -2080,7 +2080,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - without data 1`] = `
20802080
>
20812081
<div
20822082
class="rc-table-content"
2083-
style="overflow-x: scroll; overflow-y: hidden;"
2083+
style="overflow-x: auto; overflow-y: hidden;"
20842084
>
20852085
<table
20862086
style="width: 1200px; min-width: 100%; table-layout: fixed;"

tests/__snapshots__/Table.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ exports[`Table.Basic custom components renders fixed column and header correctly
125125
</div>
126126
<div
127127
class="rc-table-body"
128-
style="overflow-x: scroll; overflow-y: scroll; max-height: 100px;"
128+
style="overflow-x: auto; overflow-y: scroll; max-height: 100px;"
129129
>
130130
<table
131131
name="my-table"

0 commit comments

Comments
 (0)