Skip to content

Commit e7eddbc

Browse files
author
Hector Arce De Las Heras
committed
Bug Fixes and Input Behavior Enhancement
This commit addresses two main issues. Firstly, it fixes an error with the label position in the icon when 'informationAssociated' and 'disabled' are used, and an error when pressing the button in 'informationAssociated'. The styles have been fixed and unnecessary 'onStructureBlur/focus' have been removed. Secondly, it introduces a change to the 'useInput' hook to prevent value changes when the mouse wheel is used on a number input, avoiding unexpected behavior for the user.
1 parent 7966000 commit e7eddbc

File tree

18 files changed

+56
-87
lines changed

18 files changed

+56
-87
lines changed

src/components/input/inputStandAlone.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ const InputStandAloneComponent = (
207207
rightExtraStyles={props.rightExtraStyles}
208208
topContent={buildTopContent()}
209209
topExtraStyles={props.topExtraStyles}
210-
onBlurStructure={props.onBlurStructure}
211-
onFocusStructure={props.onFocusStructure}
212210
/>
213211
);
214212
};

src/components/input/inputUnControlled.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const InputUnControlledComponent = <V extends string | unknown>(
2626
ignoreKeys,
2727
formatNumber,
2828
locale,
29+
disabledWheelMouse = true,
2930
onBlur,
3031
onChange,
3132
onFocus,
@@ -46,8 +47,6 @@ const InputUnControlledComponent = <V extends string | unknown>(
4647
handleBlurInternal,
4748
handleFocusInternal,
4849
handleKeyDownInternal,
49-
handleBlurStructure,
50-
handleFocusStructure,
5150
} = useInput({
5251
ref,
5352
errorExecution,
@@ -69,6 +68,7 @@ const InputUnControlledComponent = <V extends string | unknown>(
6968
ignoreKeys,
7069
formatNumber,
7170
locale,
71+
disabledWheelMouse,
7272
onBlur,
7373
onChange,
7474
onFocus,
@@ -92,10 +92,8 @@ const InputUnControlledComponent = <V extends string | unknown>(
9292
type={inputType}
9393
value={value}
9494
onBlur={handleBlurInternal}
95-
onBlurStructure={handleBlurStructure}
9695
onChange={handleChangeInternal}
9796
onFocus={handleFocusInternal}
98-
onFocusStructure={handleFocusStructure}
9997
onKeyDown={handleKeyDownInternal}
10098
/>
10199
);

src/components/input/stories/argtypes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ export const argtypes = (variants: IThemeObjectVariants, themeSelected: string):
153153
category: CATEGORY_CONTROL.MODIFIERS,
154154
},
155155
},
156+
disabledWheelMouse: {
157+
description: 'Disable wheel mouse',
158+
control: { type: 'boolean' },
159+
type: { name: 'boolean' },
160+
table: {
161+
type: {
162+
summary: 'boolean',
163+
},
164+
defaultValue: { summary: true },
165+
category: CATEGORY_CONTROL.MODIFIERS,
166+
},
167+
},
156168
autoCapitalize: {
157169
description: 'Specifies whether the value of the input should be automatically capitalized',
158170
control: { type: 'select' },

src/components/input/types/input.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ export type IInputStandAlone = IInputComponents & {
351351
| 'characters'
352352
| AUTOCAPITALIZE_TYPE;
353353
disabledCopyAndPaste?: boolean;
354+
disabledWheelMouse?: boolean;
354355
maxLength?: number;
355356
minLength?: number;
356357
min?: number;
@@ -381,8 +382,6 @@ export type IInputStandAlone = IInputComponents & {
381382
onChange?: React.ChangeEventHandler<HTMLInputElement>;
382383
onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
383384
onClick?: React.MouseEventHandler<HTMLInputElement>;
384-
onFocusStructure?: React.FocusEventHandler<HTMLDivElement>;
385-
onBlurStructure?: React.FocusEventHandler<HTMLDivElement>;
386385
};
387386

388387
type propsToOmit =
@@ -404,7 +403,7 @@ export interface IInputControlled<V = undefined extends string ? unknown : strin
404403

405404
export type IInputUnControlled<V = undefined extends string ? unknown : string> = Omit<
406405
IInputControlled<V>,
407-
'value' | 'state' | 'onFocusStructure' | 'onBlurStructure'
406+
'value' | 'state'
408407
> & {
409408
// modifiers
410409
error?: boolean;

src/components/inputCounter/inputCounter.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ const InputCounterComponent = React.forwardRef(
5353
handleBlurInternal,
5454
handleFocusInternal,
5555
handleKeyDownInternal,
56-
handleBlurStructure,
57-
handleFocusStructure,
5856
} = useInput({
5957
ref,
6058
errorExecution,
@@ -96,10 +94,8 @@ const InputCounterComponent = React.forwardRef(
9694
type={type}
9795
value={value}
9896
onBlur={handleBlurInternal}
99-
onBlurStructure={handleBlurStructure}
10097
onChange={handleChangeInternal}
10198
onFocus={handleFocusInternal}
102-
onFocusStructure={handleFocusStructure}
10399
onKeyDown={handleKeyDownInternal}
104100
/>
105101
);

src/components/inputCurrency/inputCurrency.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const InputCurrencyComponent = React.forwardRef(
3333
regex,
3434
formatNumber,
3535
locale,
36+
disabledWheelMouse = true,
3637
onBlur,
3738
onChange,
3839
onFocus,
@@ -63,8 +64,6 @@ const InputCurrencyComponent = React.forwardRef(
6364
handleBlurInternal,
6465
handleFocusInternal,
6566
handleKeyDownInternal,
66-
handleBlurStructure,
67-
handleFocusStructure,
6867
} = useInput({
6968
ref,
7069
errorExecution,
@@ -87,6 +86,7 @@ const InputCurrencyComponent = React.forwardRef(
8786
regex,
8887
formatNumber,
8988
locale,
89+
disabledWheelMouse,
9090
onBlur,
9191
onChange,
9292
onFocus,
@@ -111,10 +111,8 @@ const InputCurrencyComponent = React.forwardRef(
111111
type={inputCurrencyType}
112112
value={value}
113113
onBlur={handleBlurInternal}
114-
onBlurStructure={handleBlurStructure}
115114
onChange={handleChangeInternal}
116115
onFocus={handleFocusInternal}
117-
onFocusStructure={handleFocusStructure}
118116
onKeyDown={handleKeyDownInternal}
119117
/>
120118
);

src/components/inputDate/hooks/useInputDate.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,6 @@ export const useInputDate = ({
419419
handleFocusInternal,
420420
handleKeyDownInternal,
421421
handleSetValue,
422-
handleBlurStructure,
423-
handleFocusStructure,
424422
} = useInput({
425423
ref,
426424
errorExecution,
@@ -505,7 +503,5 @@ export const useInputDate = ({
505503
handleFocusInternal,
506504
handleKeyDownInternal,
507505
handleSetValue,
508-
handleBlurStructure,
509-
handleFocusStructure,
510506
};
511507
};

src/components/inputDate/inputDate.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ const InputDateComponent = React.forwardRef(
7272
handleFocusInternal,
7373
handleKeyDownInternal,
7474
handleChangeInternal,
75-
handleBlurStructure,
76-
handleFocusStructure,
7775
} = useInputDate({
7876
ref,
7977
format,
@@ -136,13 +134,11 @@ const InputDateComponent = React.forwardRef(
136134
type={type}
137135
value={value}
138136
onBlur={handleBlurInternal}
139-
onBlurStructure={handleBlurStructure}
140137
onCalendarOpen={handleOpenCalendar}
141138
onChange={handleChangeInternal}
142139
onClick={handleClickInput}
143140
onDateChange={handlePickCalendarDate}
144141
onFocus={handleFocusInternal}
145-
onFocusStructure={handleFocusStructure}
146142
onKeyDown={handleKeyDownInternal}
147143
/>
148144
);

src/components/inputDropdown/hooks/useInputDropdown.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ type ReturnHookType = {
8484
state: InputState;
8585
handleFocusInternal: FocusEventHandler<HTMLInputElement>;
8686
handleInputPopoverChange: ChangeEventHandler<HTMLInputElement>;
87-
handleBlurStructure: FocusEventHandler<HTMLDivElement>;
88-
handleFocusStructure: FocusEventHandler<HTMLDivElement>;
8987
};
9088

9189
export const useInputDropdown = (props: ParamsType): ReturnHookType => {
@@ -141,17 +139,16 @@ export const useInputDropdown = (props: ParamsType): ReturnHookType => {
141139
};
142140

143141
// Input Basic hook
144-
const { state, inputRef, handleFocusInternal, handleBlurStructure, handleFocusStructure } =
145-
useInput({
146-
disabled: props.disabled,
147-
error: props.error || internalErrors.length > 0,
148-
// need for update the state
149-
currentValue: searchText,
150-
informationAssociated: props.informationAssociated,
151-
onFocus: props.onFocus,
152-
onBlur: handleInputBlur,
153-
onInternalErrors: props.onInternalErrors,
154-
});
142+
const { state, inputRef, handleFocusInternal } = useInput({
143+
disabled: props.disabled,
144+
error: props.error || internalErrors.length > 0,
145+
// need for update the state
146+
currentValue: searchText,
147+
informationAssociated: props.informationAssociated,
148+
onFocus: props.onFocus,
149+
onBlur: handleInputBlur,
150+
onInternalErrors: props.onInternalErrors,
151+
});
155152

156153
const useActionBottomSheet = useMemo(
157154
() => props.styles?.[state]?.useActionBottomSheet?.[device],
@@ -382,7 +379,5 @@ export const useInputDropdown = (props: ParamsType): ReturnHookType => {
382379
listOptionsHeight,
383380
handleFocusInternal,
384381
handleInputPopoverChange,
385-
handleBlurStructure,
386-
handleFocusStructure,
387382
};
388383
};

src/components/inputDropdown/inputDropdown.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ const InputDropdownComponent = React.forwardRef(
6464
handleFocusInternal,
6565
handleInputPopoverChange,
6666
handleInputPopoverKeyDown,
67-
handleBlurStructure,
68-
handleFocusStructure,
6967
} = useInputDropdown({
7068
open,
7169
optionList,
@@ -106,11 +104,9 @@ const InputDropdownComponent = React.forwardRef(
106104
type={type}
107105
value={valueSearchSelected}
108106
onBlur={handleInputBlur}
109-
onBlurStructure={handleBlurStructure}
110107
onChange={handleChangeInputDropdown}
111108
onClick={handleClickInputDropdown}
112109
onFocus={handleFocusInternal}
113-
onFocusStructure={handleFocusStructure}
114110
onInputPopoverChange={handleInputPopoverChange}
115111
onInputPopoverIconClick={handleInputPopoverIconClick}
116112
onInputPopoverKeyDown={handleInputPopoverKeyDown}

0 commit comments

Comments
 (0)