diff --git a/.dumi/theme/common/styles/Demo.tsx b/.dumi/theme/common/styles/Demo.tsx index 77eabf85e720..5b0a04c1dd1b 100644 --- a/.dumi/theme/common/styles/Demo.tsx +++ b/.dumi/theme/common/styles/Demo.tsx @@ -22,13 +22,13 @@ const GlobalDemoStyles: React.FC = () => { .code-box { position: relative; display: inline-block; - /* width: calc(100% - ${token.lineWidth * 2}px); */ - width: 100%; + width: calc(100% - ${token.lineWidth * 2}px); margin: 0 0 ${token.margin}px; background-color: ${token.colorBgContainer}; - border: 1px solid ${token.colorSplit}; + border: ${token.lineWidth}px ${token.lineType} ${token.colorSplit}; border-radius: ${token.borderRadiusLG}px; transition: all ${token.motionDurationMid}; + box-sizing: content-box; &.code-box-simplify { border-radius: 0; diff --git a/components/descriptions/Row.tsx b/components/descriptions/Row.tsx index c8103ca64a8f..593df00b5225 100644 --- a/components/descriptions/Row.tsx +++ b/components/descriptions/Row.tsx @@ -42,10 +42,12 @@ function renderCells( }, index, ) => { + const mergedKey = key ?? index; + if (typeof component === 'string') { return ( , { @@ -284,6 +284,29 @@ describe('Descriptions', () => { expect(jest.spyOn(document, 'createElement')).not.toHaveBeenCalled(); }); + it('should preserve item state after reordering when key is 0', () => { + const items = [ + { + key: 0, + label: 'Zero', + children: , + }, + { + key: 2, + label: 'Two', + children: , + }, + ]; + const { getByLabelText, rerender } = render(); + const input = getByLabelText('Zero value'); + + fireEvent.change(input, { target: { value: 'edited' } }); + rerender(); + + expect(getByLabelText('Zero value')).toBe(input); + expect(getByLabelText('Zero value')).toHaveValue('edited'); + }); + // https://github.com/ant-design/ant-design/issues/19887 it('should work with React Fragment', () => { if (!React.Fragment) {