Skip to content

Commit

Permalink
fix(Select): native onCompositionStart onCompositionEnd fix alibaba-f…
Browse files Browse the repository at this point in the history
  • Loading branch information
bindoon authored and youluna committed Jul 27, 2021
1 parent 4416c62 commit 0b24e3a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/input/base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,17 @@ class Base extends React.Component {
}

getProps() {
const { placeholder, inputStyle, disabled, readOnly, cutString, maxLength, name } = this.props;
const {
placeholder,
inputStyle,
disabled,
readOnly,
cutString,
maxLength,
name,
onCompositionStart,
onCompositionEnd,
} = this.props;
const props = {
style: inputStyle,
placeholder,
Expand All @@ -286,6 +296,8 @@ class Base extends React.Component {
onChange: this.onChange.bind(this),
onBlur: this.onBlur.bind(this),
onFocus: this.onFocus.bind(this),
onCompositionStart,
onCompositionEnd,
};

// fix accessibility:auto process status of aria disabled
Expand Down
20 changes: 20 additions & 0 deletions test/input/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,26 @@ describe('input', () => {
assert(onCompositionEnd.calledOnce);
assert(onChange.calledOnce);
});

it('Navitve onCompositionStart/onCompositionUpdate/onCompositionEnd events', () => {
const onCompositionStart = sinon.spy();
const onCompositionUpdate = sinon.spy();
const onCompositionEnd = sinon.spy();
const wrapper = mount(
<Input
onCompositionStart={onCompositionStart}
onCompositionUpdate={onCompositionUpdate}
onCompositionEnd={onCompositionEnd}
/>
);
wrapper.find('input').simulate('compositionstart', { target: { value: 'zh' } });
assert(onCompositionStart.calledOnce);
wrapper.find('input').simulate('compositionupdate', { target: { value: 'zhon' } });
assert(onCompositionUpdate.calledOnce);
wrapper.find('input').simulate('compositionend', { target: { value: '中' } });
assert(onCompositionEnd.calledOnce);
});

it('should support onChange', done => {
let onChange = value => {
assert(value === '20');
Expand Down

0 comments on commit 0b24e3a

Please sign in to comment.