Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tabs] Remove duplicate styles #23561

Merged
merged 5 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/material-ui/src/Tab/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ export const styles = (theme) => ({
minHeight: 48,
flexShrink: 0,
padding: '6px 12px',
[theme.breakpoints.up('sm')]: {
padding: '6px 24px',
},
overflow: 'hidden',
whiteSpace: 'normal',
textAlign: 'center',
Expand Down
50 changes: 25 additions & 25 deletions packages/material-ui/src/Tabs/Tabs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ describe('<Tabs />', () => {
let clock;
const tabs = (
<Tabs value={0} style={{ width: 200 }} variant="scrollable">
<Tab />
<Tab />
<Tab />
<Tab style={{ width: 120 }} />
<Tab style={{ width: 120 }} />
<Tab style={{ width: 120 }} />
</Tabs>
);

Expand All @@ -376,7 +376,7 @@ describe('<Tabs />', () => {
const { container, setProps, getByRole } = render(tabs);
const tablistContainer = getByRole('tablist').parentElement;

Object.defineProperty(tablistContainer, 'clientWidth', { value: 120 });
Object.defineProperty(tablistContainer, 'clientWidth', { value: 200 - 40 * 2 });
tablistContainer.scrollLeft = 10;
Object.defineProperty(tablistContainer, 'scrollWidth', { value: 216 });
Object.defineProperty(tablistContainer, 'getBoundingClientRect', {
Expand Down Expand Up @@ -475,7 +475,7 @@ describe('<Tabs />', () => {

const tablistContainer = getByRole('tablist').parentElement;

Object.defineProperty(tablistContainer, 'clientWidth', { value: 120 });
Object.defineProperty(tablistContainer, 'clientWidth', { value: 200 - 40 * 2 });
tablistContainer.scrollLeft = 10;
Object.defineProperty(tablistContainer, 'scrollWidth', { value: 216 });
Object.defineProperty(tablistContainer, 'getBoundingClientRect', {
Expand Down Expand Up @@ -518,14 +518,14 @@ describe('<Tabs />', () => {
it('should set only left scroll button state', () => {
const { container, setProps, getByRole } = render(
<Tabs value={0} variant="scrollable" scrollButtons style={{ width: 200 }}>
<Tab />
<Tab />
<Tab />
<Tab style={{ width: 120 }} />
<Tab style={{ width: 120 }} />
<Tab style={{ width: 120 }} />
</Tabs>,
);
const tablistContainer = getByRole('tablist').parentElement;

Object.defineProperty(tablistContainer, 'clientWidth', { value: 120 });
Object.defineProperty(tablistContainer, 'clientWidth', { value: 200 - 40 * 2 });
Object.defineProperty(tablistContainer, 'scrollWidth', { value: 216 });
tablistContainer.scrollLeft = 96;

Expand All @@ -544,7 +544,7 @@ describe('<Tabs />', () => {
);
const tablistContainer = getByRole('tablist').parentElement;

Object.defineProperty(tablistContainer, 'clientWidth', { value: 120 });
Object.defineProperty(tablistContainer, 'clientWidth', { value: 200 - 40 * 2 });
Object.defineProperty(tablistContainer, 'scrollWidth', { value: 216 });
tablistContainer.scrollLeft = 0;

Expand All @@ -556,13 +556,13 @@ describe('<Tabs />', () => {
it('should set both left and right scroll button state', () => {
const { container, setProps, getByRole } = render(
<Tabs value={0} variant="scrollable" scrollButtons style={{ width: 200 }}>
<Tab />
<Tab />
<Tab style={{ width: 120 }} />
<Tab style={{ width: 120 }} />
</Tabs>,
);
const tablistContainer = getByRole('tablist').parentElement;

Object.defineProperty(tablistContainer, 'clientWidth', { value: 120 });
Object.defineProperty(tablistContainer, 'clientWidth', { value: 200 - 40 * 2 });
Object.defineProperty(tablistContainer, 'scrollWidth', { value: 216 });
tablistContainer.scrollLeft = 5;

Expand All @@ -587,18 +587,18 @@ describe('<Tabs />', () => {
it('should scroll visible items', () => {
const { container, setProps, getByRole, getAllByRole } = render(
<Tabs value={0} variant="scrollable" scrollButtons style={{ width: 200 }}>
<Tab />
<Tab />
<Tab />
<Tab style={{ width: 100 }} />
<Tab style={{ width: 50 }} />
<Tab style={{ width: 100 }} />
</Tabs>,
);
const tablistContainer = getByRole('tablist').parentElement;
const tabs = getAllByRole('tab');
Object.defineProperty(tablistContainer, 'clientWidth', { value: 120 });
Object.defineProperty(tabs[0], 'clientWidth', { value: 60 });
Object.defineProperty(tablistContainer, 'clientWidth', { value: 200 - 40 * 2 });
Object.defineProperty(tabs[0], 'clientWidth', { value: 100 });
Object.defineProperty(tabs[1], 'clientWidth', { value: 50 });
Object.defineProperty(tabs[2], 'clientWidth', { value: 60 });
Object.defineProperty(tablistContainer, 'scrollWidth', { value: 216 });
Object.defineProperty(tabs[2], 'clientWidth', { value: 100 });
Object.defineProperty(tablistContainer, 'scrollWidth', { value: 100 + 50 + 100 });
tablistContainer.scrollLeft = 20;
setProps();
clock.tick(1000);
Expand All @@ -612,7 +612,7 @@ describe('<Tabs />', () => {
tablistContainer.scrollLeft = 0;
fireEvent.click(findScrollButton(container, 'right'));
clock.tick(1000);
expect(tablistContainer.scrollLeft).equal(60 + 50);
expect(tablistContainer.scrollLeft).equal(100);
});
});

Expand All @@ -634,16 +634,16 @@ describe('<Tabs />', () => {

const { setProps, getByRole } = render(
<Tabs value={0} variant="scrollable" style={{ width: 200 }}>
<Tab />
<Tab />
<Tab />
<Tab style={{ width: 120 }} />
<Tab style={{ width: 120 }} />
<Tab style={{ width: 120 }} />
</Tabs>,
);
const tablist = getByRole('tablist');
const tablistContainer = tablist.parentElement;
const tab = tablist.children[0];

Object.defineProperty(tablistContainer, 'clientWidth', { value: 120 });
Object.defineProperty(tablistContainer, 'clientWidth', { value: 200 - 40 * 2 });
Object.defineProperty(tablistContainer, 'scrollWidth', { value: 216 });
tablistContainer.scrollLeft = 20;
tablistContainer.getBoundingClientRect = () => ({
Expand Down