Browse Source

fix(Grid): Row justify setting space-evenly does not work (#41679)

pull/41692/head
JiaQi 2 years ago
committed by GitHub
parent
commit
bebc05196d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      components/grid/__tests__/index.test.tsx
  2. 6
      components/grid/style/index.ts

15
components/grid/__tests__/index.test.tsx

@ -3,8 +3,8 @@ import { act } from 'react-dom/test-utils';
import { Col, Row } from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { fireEvent, render } from '../../../tests/utils';
import useBreakpoint from '../hooks/useBreakpoint';
import { render, fireEvent } from '../../../tests/utils';
// Mock for `responsiveObserve` to test `unsubscribe` call
jest.mock('../../_util/responsiveObserver', () => {
@ -232,4 +232,17 @@ describe('Grid', () => {
});
expect(container.innerHTML).toContain('ant-row-end');
});
it('The column spacing should be evenly spaced', () => {
const { container } = render(
<Row justify="space-evenly">
<Col span={4}>col-1</Col>
<Col span={4}>col-2</Col>
</Row>,
);
const row = container.querySelector('.ant-row-space-evenly');
expect(row).toBeTruthy();
expect(row && getComputedStyle(row).justifyContent).toEqual('space-evenly');
});
});

6
components/grid/style/index.ts

@ -46,10 +46,14 @@ const genGridRowStyle: GenerateStyle<GridRowToken> = (token): CSSObject => {
justifyContent: 'space-between',
},
'&-space-around ': {
'&-space-around': {
justifyContent: 'space-around',
},
'&-space-evenly': {
justifyContent: 'space-evenly',
},
// Align at the top
'&-top': {
alignItems: 'flex-start',

Loading…
Cancel
Save