mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 09:39:18 +08:00
parent
88bed67368
commit
eea0b028c9
@ -46,8 +46,11 @@ class Editable extends React.Component<EditableProps, EditableState> {
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
if (this.textarea) {
|
||||
this.textarea.focus();
|
||||
if (this.textarea && this.textarea.resizableTextArea) {
|
||||
const { textArea } = this.textarea.resizableTextArea;
|
||||
textArea.focus();
|
||||
const { length } = textArea.value;
|
||||
textArea.setSelectionRange(length, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,6 +241,17 @@ describe('Typography', () => {
|
||||
wrapper.find('TextArea').simulate('blur');
|
||||
});
|
||||
});
|
||||
|
||||
it('should focus at the end of textarea', () => {
|
||||
const wrapper = mount(<Paragraph editable>content</Paragraph>);
|
||||
wrapper
|
||||
.find('.ant-typography-edit')
|
||||
.first()
|
||||
.simulate('click');
|
||||
const textareaNode = wrapper.find('textarea').getDOMNode();
|
||||
expect(textareaNode.selectionStart).toBe(7);
|
||||
expect(textareaNode.selectionEnd).toBe(7);
|
||||
});
|
||||
});
|
||||
|
||||
it('warning if use setContentRef', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user