Skip to content

Commit

Permalink
fix(textarea-control): ace editor input exception (apache#18146)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenLYZ authored and bwang221 committed Feb 10, 2022
1 parent 78dfcd8 commit 6198508
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export default class TextAreaControl extends React.Component {
this.props.onChange(value);
}

onAreaEditorChange(value) {
this.props.onChange(value);
}

renderEditor(inModal = false) {
const minLines = inModal ? 40 : this.props.minLines || 12;
if (this.props.language) {
Expand All @@ -76,14 +80,14 @@ export default class TextAreaControl extends React.Component {
style={style}
minLines={minLines}
maxLines={inModal ? 1000 : this.props.maxLines}
onChange={this.props.onChange}
width="100%"
height={`${minLines}em`}
editorProps={{ $blockScrolling: true }}
defaultValue={this.props.initialValue}
readOnly={this.props.readOnly}
key={this.props.name}
{...this.props}
onChange={this.onAreaEditorChange.bind(this)}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ describe('TextArea', () => {
expect(wrapper.find(TextArea)).not.toExist();
expect(wrapper.find(TextAreaEditor)).toExist();
});

it('calls onAreaEditorChange when entering in the AceEditor', () => {
const props = { ...defaultProps };
props.language = 'markdown';
wrapper = shallow(<TextAreaControl {...props} />);
wrapper.simulate('change', { target: { value: 'x' } });
expect(defaultProps.onChange.calledWith('x')).toBe(true);
});
});

0 comments on commit 6198508

Please sign in to comment.