Skip to content

Commit

Permalink
πŸ› fix(field): textarea stopPropagation enter (ant-design#1026)
Browse files Browse the repository at this point in the history
* πŸ› fix(field): textarea stopPropagation enter

* add test

* add test

* add test

* add test
  • Loading branch information
chenshuai2144 committed Nov 19, 2020
1 parent 19d3af5 commit 98a1876
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/field/src/components/TextArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const FieldTextArea: ProFieldFC<{
const dom = (
<Input.TextArea
rows={3}
onKeyPress={(e) => {
if (e.key === 'Enter') e.stopPropagation();
}}
placeholder={intl.getMessage('tableForm.inputPlaceholder', 'θ―·θΎ“ε…₯')}
ref={ref}
{...fieldProps}
Expand Down
16 changes: 16 additions & 0 deletions tests/field/field.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,20 @@ describe('Field', () => {
);
expect(html.text()).toBe('qixian');
});

it('🐴 keypress simulate', () => {
const html = mount(<Field text="qixian" valueType="textarea" mode="edit" />);
act(() => {
html.find('TextArea').at(0).simulate('keypress', {
key: 'Enter',
keyCode: 13,
});
});
act(() => {
html.setProps({
mode: 'read',
});
});
expect(html.text()).toBe('qixian');
});
});

0 comments on commit 98a1876

Please sign in to comment.