Skip to content

Commit

Permalink
fix(sortableList):column list control (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmclin2 committed Mar 11, 2024
1 parent d41ed46 commit e1e7a1c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ant-design/pro-editor",
"version": "1.0.0",
"version": "1.0.1",
"description": "🌟 Lightweight Editor UI Framework",
"homepage": "https://github.com/ant-design/pro-editor",
"bugs": {
Expand Down
43 changes: 43 additions & 0 deletions src/SortableList/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { act, fireEvent, render } from '@testing-library/react';
import { Button } from 'antd';
import { useState } from 'react';
import { SortableList } from '../index';

const Demo = () => {
const [list, setList] = useState(['hello', 'world']);

return (
<>
<SortableList
value={list}
onChange={(value) => {
console.log('change value', value);
setList(value);
}}
SHOW_STORE_IN_DEVTOOLS
/>
<Button
type="primary"
onClick={() => {
setList(['foo', 'bar', 'yes']);
}}
style={{ marginTop: 8 }}
>
Set Data
</Button>
</>
);
};

describe('SortableList', () => {
it('toggleSetData', () => {
const { getByText } = render(<Demo />);
const setDataButton = getByText('Set Data');
act(() => {
fireEvent.click(setDataButton);
});
expect(getByText('foo')).toBeInTheDocument();
expect(getByText('bar')).toBeInTheDocument();
expect(getByText('yes')).toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion src/SortableList/container/StoreUpdater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const StoreUpdater = forwardRef(
useStoreUpdater('initialValues', initialValues, [], (state) => {
KeyManagerUpdater(state, 'initialValues');
});
useStoreUpdater('value', value, [], (state) => {
useStoreUpdater('value', value, [value], (state) => {
KeyManagerUpdater(state, 'value');
});
useStoreUpdater('actions', actions);
Expand Down

0 comments on commit e1e7a1c

Please sign in to comment.