fix: input compositionend not trigger change

pull/2900/head
tangjinzhou 2020-09-22 07:25:44 +08:00
parent 122e374224
commit 7ea8de4b7e
7 changed files with 77 additions and 52 deletions

View File

@ -8,6 +8,8 @@ import BaseMixin from '../_util/BaseMixin';
import inputProps from './inputProps'; import inputProps from './inputProps';
import PropTypes from '../_util/vue-types'; import PropTypes from '../_util/vue-types';
import { getOptionProps } from '../_util/props-util'; import { getOptionProps } from '../_util/props-util';
import { withDirectives } from 'vue';
import antInput from '../_util/antInputDirective';
const RESIZE_STATUS_NONE = 0; const RESIZE_STATUS_NONE = 0;
const RESIZE_STATUS_RESIZING = 1; const RESIZE_STATUS_RESIZING = 1;
@ -139,7 +141,7 @@ const ResizableTextArea = {
} }
return ( return (
<ResizeObserver onResize={this.handleResize} disabled={!(autoSize || autosize)}> <ResizeObserver onResize={this.handleResize} disabled={!(autoSize || autosize)}>
<textarea {...textareaProps} ref={this.saveTextArea} /> {withDirectives(<textarea {...textareaProps} ref={this.saveTextArea} />, [[antInput]])}
</ResizeObserver> </ResizeObserver>
); );
}, },

View File

@ -4,6 +4,8 @@ import { getComponent, findDOMNode } from '../../../_util/props-util';
import moment from 'moment'; import moment from 'moment';
import { formatDate } from '../util'; import { formatDate } from '../util';
import KeyCode from '../../../_util/KeyCode'; import KeyCode from '../../../_util/KeyCode';
import { withDirectives } from 'vue';
import antInput from '../../../_util/antInputDirective';
let cachedSelectionStart; let cachedSelectionStart;
let cachedSelectionEnd; let cachedSelectionEnd;
@ -193,20 +195,23 @@ const DateInput = {
return ( return (
<div class={`${prefixCls}-input-wrap`}> <div class={`${prefixCls}-input-wrap`}>
<div class={`${prefixCls}-date-input-wrap`}> <div class={`${prefixCls}-date-input-wrap`}>
<input {withDirectives(
ref={this.saveDateInput} <input
class={`${prefixCls}-input ${invalidClass}`} ref={this.saveDateInput}
value={str} class={`${prefixCls}-input ${invalidClass}`}
disabled={disabled} value={str}
placeholder={placeholder} disabled={disabled}
onInput={this.onInputChange} placeholder={placeholder}
onChange={this.onInputChange} onInput={this.onInputChange}
onKeydown={this.onKeyDown} onChange={this.onInputChange}
onFocus={this.onFocus} onKeydown={this.onKeyDown}
onBlur={this.onBlur} onFocus={this.onFocus}
inputMode={inputMode} onBlur={this.onBlur}
readonly={inputReadOnly} inputMode={inputMode}
/> readonly={inputReadOnly}
/>,
[[antInput]],
)}
</div> </div>
{showClear ? ( {showClear ? (
<a role="button" title={locale.clear} onClick={this.onClear}> <a role="button" title={locale.clear} onClick={this.onClear}>

View File

@ -1,4 +1,4 @@
import { provide } from 'vue'; import { provide, withDirectives } from 'vue';
import classNames from '../../_util/classNames'; import classNames from '../../_util/classNames';
import omit from 'omit.js'; import omit from 'omit.js';
import KeyCode from '../../_util/KeyCode'; import KeyCode from '../../_util/KeyCode';
@ -13,6 +13,7 @@ import {
} from './util'; } from './util';
import KeywordTrigger from './KeywordTrigger'; import KeywordTrigger from './KeywordTrigger';
import { vcMentionsProps, defaultProps } from './mentionsProps'; import { vcMentionsProps, defaultProps } from './mentionsProps';
import antInput from '../../_util/antInputDirective';
function noop() {} function noop() {}
@ -286,7 +287,7 @@ const Mentions = {
}; };
return ( return (
<div class={classNames(prefixCls, className)} style={style}> <div class={classNames(prefixCls, className)} style={style}>
<textarea ref="textarea" {...textareaProps} /> {withDirectives(<textarea ref="textarea" {...textareaProps} />, [[antInput]])}
{measuring && ( {measuring && (
<div ref="measure" class={`${prefixCls}-measure`}> <div ref="measure" class={`${prefixCls}-measure`}>
{value.slice(0, measureLocation)} {value.slice(0, measureLocation)}

View File

@ -1,6 +1,8 @@
import PropTypes from '../_util/vue-types'; import PropTypes from '../_util/vue-types';
import KEYCODE from './KeyCode'; import KEYCODE from './KeyCode';
import BaseMixin from '../_util/BaseMixin'; import BaseMixin from '../_util/BaseMixin';
import { withDirectives } from 'vue';
import antInput from '../_util/antInputDirective';
export default { export default {
mixins: [BaseMixin], mixins: [BaseMixin],
@ -131,15 +133,18 @@ export default {
goInput = ( goInput = (
<div class={`${prefixCls}-quick-jumper`}> <div class={`${prefixCls}-quick-jumper`}>
{locale.jump_to} {locale.jump_to}
<input {withDirectives(
disabled={disabled} <input
type="text" disabled={disabled}
value={goInputText} type="text"
onInput={this.handleChange} value={goInputText}
onChange={this.handleChange} onInput={this.handleChange}
onKeyup={this.go} onChange={this.handleChange}
onBlur={this.handleBlur} onKeyup={this.go}
/> onBlur={this.handleBlur}
/>,
[[antInput]],
)}
{locale.page} {locale.page}
{gotoButton} {gotoButton}
</div> </div>

View File

@ -6,6 +6,8 @@ import Options from './Options';
import LOCALE from './locale/zh_CN'; import LOCALE from './locale/zh_CN';
import KEYCODE from './KeyCode'; import KEYCODE from './KeyCode';
import classNames from '../_util/classNames'; import classNames from '../_util/classNames';
import { withDirectives } from 'vue';
import antInput from '../_util/antInputDirective';
function noop() {} function noop() {}
@ -379,15 +381,18 @@ export default {
title={this.showTitle ? `${stateCurrent}/${allPages}` : null} title={this.showTitle ? `${stateCurrent}/${allPages}` : null}
class={`${prefixCls}-simple-pager`} class={`${prefixCls}-simple-pager`}
> >
<input {withDirectives(
type="text" <input
value={this.stateCurrentInputValue} type="text"
onKeydown={this.handleKeyDown} value={this.stateCurrentInputValue}
onKeyup={this.handleKeyUp} onKeydown={this.handleKeyDown}
onInput={this.handleKeyUp} onKeyup={this.handleKeyUp}
onChange={this.handleKeyUp} onInput={this.handleKeyUp}
size="3" onChange={this.handleKeyUp}
/> size="3"
/>,
[[antInput]],
)}
<span class={`${prefixCls}-slash`}></span> <span class={`${prefixCls}-slash`}></span>
{allPages} {allPages}
</li> </li>

View File

@ -1,6 +1,8 @@
import PropTypes from '../_util/vue-types'; import PropTypes from '../_util/vue-types';
import BaseMixin from '../_util/BaseMixin'; import BaseMixin from '../_util/BaseMixin';
import moment from 'moment'; import moment from 'moment';
import { withDirectives } from 'vue';
import antInput from '../_util/antInputDirective';
const Header = { const Header = {
inheritAttrs: false, inheritAttrs: false,
@ -159,7 +161,7 @@ const Header = {
getInput() { getInput() {
const { prefixCls, placeholder, inputReadOnly, invalid, str } = this; const { prefixCls, placeholder, inputReadOnly, invalid, str } = this;
const invalidClass = invalid ? `${prefixCls}-input-invalid` : ''; const invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
return ( return withDirectives(
<input <input
class={`${prefixCls}-input ${invalidClass}`} class={`${prefixCls}-input ${invalidClass}`}
ref={ref => { ref={ref => {
@ -171,7 +173,8 @@ const Header = {
onInput={this.onInputChange} onInput={this.onInputChange}
onChange={this.onInputChange} onChange={this.onInputChange}
readonly={!!inputReadOnly} readonly={!!inputReadOnly}
/> />,
[[antInput]],
); );
}, },
}, },

View File

@ -4,7 +4,8 @@
* - multiple: in the selector * - multiple: in the selector
* Move the code as a SearchInput for easy management. * Move the code as a SearchInput for easy management.
*/ */
import { inject } from 'vue'; import { inject, withDirectives } from 'vue';
import antInput from '../../_util/antInputDirective';
import PropTypes from '../../_util/vue-types'; import PropTypes from '../../_util/vue-types';
import { createRef } from './util'; import { createRef } from './util';
@ -118,20 +119,23 @@ const SearchInput = {
} = this; } = this;
return ( return (
<span class={`${prefixCls}-search__field__wrap`}> <span class={`${prefixCls}-search__field__wrap`}>
<input {withDirectives(
type="text" <input
ref={this.inputRef} type="text"
onInput={handleInputChange} ref={this.inputRef}
onChange={handleInputChange} onInput={handleInputChange}
onKeydown={onSearchInputKeyDown} onChange={handleInputChange}
value={searchValue} onKeydown={onSearchInputKeyDown}
disabled={disabled} value={searchValue}
class={`${prefixCls}-search__field`} disabled={disabled}
aria-label="filter select" class={`${prefixCls}-search__field`}
aria-autocomplete="list" aria-label="filter select"
aria-controls={open ? ariaId : undefined} aria-autocomplete="list"
aria-multiline="false" aria-controls={open ? ariaId : undefined}
/> aria-multiline="false"
/>,
[[antInput]],
)}
<span ref={this.mirrorInputRef} class={`${prefixCls}-search__field__mirror`}> <span ref={this.mirrorInputRef} class={`${prefixCls}-search__field__mirror`}>
{mirrorSearchValue}&nbsp; {mirrorSearchValue}&nbsp;
</span> </span>