Pārlūkot izejas kodu

fix: remove useless setPaddingLeft call in input, close #1262, 1181 (#1265)

pointhalo 2 gadi atpakaļ
vecāks
revīzija
b5c71ff95c

+ 0 - 5
packages/semi-foundation/input/foundation.ts

@@ -21,7 +21,6 @@ export interface InputAdapter extends Partial<DefaultAdapter>, Partial<InputDefa
     notifyKeyUp(e: any): void;
     notifyKeyPress(e: any): void;
     notifyEnterPress(e: any): void;
-    setPaddingLeft(paddingLeft: string): void;
     isEventTarget(e: any): boolean
 }
 
@@ -266,10 +265,6 @@ class InputFoundation extends BaseFoundation<InputAdapter> {
         }
     }
 
-    setPaddingLeft(paddingLeft: string) {
-        this._adapter.setPaddingLeft(paddingLeft);
-    }
-
     isAllowClear() {
         const { value, isFocus, isHovering } = this._adapter.getStates();
         const { showClear, disabled } = this._adapter.getProps();

+ 2 - 5
packages/semi-ui/input/index.tsx

@@ -72,7 +72,6 @@ export interface InputState {
     cachedValue: React.ReactText;
     disabled: boolean;
     props: Record<string, any>;
-    paddingLeft: string;
     isFocus: boolean;
     isHovering: boolean;
     eyeClosed: boolean;
@@ -157,7 +156,6 @@ class Input extends BaseComponent<InputProps, InputState> {
             cachedValue: null, // Cache current props.value value
             disabled: false,
             props: {},
-            paddingLeft: '',
             isFocus: false,
             isHovering: false,
             eyeClosed: props.mode === 'password',
@@ -195,7 +193,6 @@ class Input extends BaseComponent<InputProps, InputState> {
             notifyKeyUp: (e: React.KeyboardEvent<HTMLInputElement>) => this.props.onKeyUp(e),
             notifyEnterPress: (e: React.KeyboardEvent<HTMLInputElement>) => this.props.onEnterPress(e),
             notifyClear: (e: React.MouseEvent<HTMLDivElement>) => this.props.onClear(e),
-            setPaddingLeft: (paddingLeft: string) => this.setState({ paddingLeft }),
             setMinLength: (minLength: number) => this.setState({ minLength }),
             isEventTarget: (e: React.MouseEvent) => e && e.target === e.currentTarget,
         };
@@ -429,7 +426,7 @@ class Input extends BaseComponent<InputProps, InputState> {
             preventScroll,
             ...rest
         } = this.props;
-        const { value, paddingLeft, isFocus, minLength: stateMinLength } = this.state;
+        const { value, isFocus, minLength: stateMinLength } = this.state;
         const suffixAllowClear = this.showClearBtn();
         const suffixIsIcon = isSemiIcon(suffix);
         const ref = forwardRef || this.inputRef;
@@ -462,7 +459,7 @@ class Input extends BaseComponent<InputProps, InputState> {
         const inputValue = value === null || value === undefined ? '' : value;
         const inputProps: React.InputHTMLAttributes<HTMLInputElement> = {
             ...rest,
-            style: { paddingLeft, ...inputStyle },
+            style: inputStyle,
             autoFocus: autofocus,
             className: inputCls,
             disabled,