|
@@ -207,6 +207,10 @@ class Input extends BaseComponent<InputProps, InputState> {
|
|
|
this.foundation.handleClear(e);
|
|
|
};
|
|
|
|
|
|
+ handleClearEnterPress = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
|
+ this.foundation.handleClearEnterPress(e);
|
|
|
+ };
|
|
|
+
|
|
|
handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
|
this.foundation.handleClick(e);
|
|
|
};
|
|
@@ -235,6 +239,10 @@ class Input extends BaseComponent<InputProps, InputState> {
|
|
|
this.foundation.handleMouseUp(e);
|
|
|
};
|
|
|
|
|
|
+ handleModeEnterPress = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
|
+ this.foundation.handleModeEnterPress(e);
|
|
|
+ }
|
|
|
+
|
|
|
handleClickPrefixOrSuffix = (e: React.MouseEvent<HTMLInputElement>) => {
|
|
|
this.foundation.handleClickPrefixOrSuffix(e);
|
|
|
};
|
|
@@ -275,7 +283,14 @@ class Input extends BaseComponent<InputProps, InputState> {
|
|
|
// use onMouseDown to fix issue 1203
|
|
|
if (allowClear) {
|
|
|
return (
|
|
|
- <div className={clearCls} onMouseDown={this.handleClear}>
|
|
|
+ <div
|
|
|
+ role="button"
|
|
|
+ tabIndex={0}
|
|
|
+ aria-label="Clear input value"
|
|
|
+ className={clearCls}
|
|
|
+ onMouseDown={this.handleClear}
|
|
|
+ onKeyPress={this.handleClearEnterPress}
|
|
|
+ >
|
|
|
<IconClear />
|
|
|
</div>
|
|
|
);
|
|
@@ -289,9 +304,19 @@ class Input extends BaseComponent<InputProps, InputState> {
|
|
|
const modeCls = cls(`${prefixCls}-modebtn`);
|
|
|
const modeIcon = eyeClosed ? <IconEyeClosedSolid /> : <IconEyeOpened />;
|
|
|
const showModeBtn = mode === 'password' && value && !disabled && (isFocus || isHovering);
|
|
|
+ const ariaLabel = eyeClosed ? 'Show password' : 'Hidden password'
|
|
|
if (showModeBtn) {
|
|
|
return (
|
|
|
- <div className={modeCls} onClick={this.handleClickEye} onMouseDown={this.handleMouseDown} onMouseUp={this.handleMouseUp}>
|
|
|
+ <div
|
|
|
+ role="button"
|
|
|
+ tabIndex={0}
|
|
|
+ aria-label={ariaLabel}
|
|
|
+ className={modeCls}
|
|
|
+ onClick={this.handleClickEye}
|
|
|
+ onMouseDown={this.handleMouseDown}
|
|
|
+ onMouseUp={this.handleMouseUp}
|
|
|
+ onKeyPress={this.handleModeEnterPress}
|
|
|
+ >
|
|
|
{modeIcon}
|
|
|
</div>
|
|
|
);
|
|
@@ -312,6 +337,7 @@ class Input extends BaseComponent<InputProps, InputState> {
|
|
|
[`${prefixCls}-prefix-icon`]: isSemiIcon(labelNode),
|
|
|
});
|
|
|
|
|
|
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
|
return <div className={prefixWrapperCls} onMouseDown={this.handlePreventMouseDown} onClick={this.handleClickPrefixOrSuffix}>{labelNode}</div>;
|
|
|
}
|
|
|
|
|
@@ -332,6 +358,7 @@ class Input extends BaseComponent<InputProps, InputState> {
|
|
|
[`${prefixCls }-suffix-icon`]: isSemiIcon(suffix),
|
|
|
[`${prefixCls}-suffix-hidden`]: suffixAllowClear && Boolean(hideSuffix),
|
|
|
});
|
|
|
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
|
return <div className={suffixWrapperCls} onMouseDown={this.handlePreventMouseDown} onClick={this.handleClickPrefixOrSuffix}>{suffix}</div>;
|
|
|
}
|
|
|
|
|
@@ -417,7 +444,11 @@ class Input extends BaseComponent<InputProps, InputState> {
|
|
|
if (stateMinLength) {
|
|
|
inputProps.minLength = stateMinLength;
|
|
|
}
|
|
|
+ if (validateStatus === 'error') {
|
|
|
+ inputProps['aria-invalid'] = "true";
|
|
|
+ }
|
|
|
return (
|
|
|
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
|
<div
|
|
|
className={wrapperCls}
|
|
|
style={style}
|