Skip to content

Commit 11dcb5b

Browse files
mkk55Mikk Orasmaa
andauthored
fix(textfield): Move tabIndex attribute to input element #564 (#565)
* fix(textfield): Move tabIndex attribute to input element (#564) * fix(textfield): Move tabIndex attribute to input element (#564) --------- Co-authored-by: Mikk Orasmaa <mikk.orasmaa@nortal.com>
1 parent 4ccbd7c commit 11dcb5b

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/tedi/components/form/textfield/textfield.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ $input-padding-right-map: (
5454

5555
.tedi-textfield__inner {
5656
position: relative;
57+
58+
&:focus-within {
59+
@include mixins.focus-element;
60+
}
5761
}
5862

5963
.tedi-textfield__input {

src/tedi/components/form/textfield/textfield.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,23 @@ export const TextField = forwardRef<TextFieldForwardRef, TextFieldProps>((props,
305305
};
306306

307307
if (isTextAreaRef(props, inputRef)) {
308-
return <textarea {...(sharedProps as React.TextareaHTMLAttributes<HTMLTextAreaElement>)} ref={inputRef} />;
308+
return (
309+
<textarea
310+
{...(sharedProps as React.TextareaHTMLAttributes<HTMLTextAreaElement>)}
311+
ref={inputRef}
312+
tabIndex={disabled ? -1 : 0}
313+
/>
314+
);
309315
}
310316

311317
if (isInputRef(props, inputRef)) {
312-
return <input {...(sharedProps as React.InputHTMLAttributes<HTMLInputElement>)} ref={inputRef} />;
318+
return (
319+
<input
320+
{...(sharedProps as React.InputHTMLAttributes<HTMLInputElement>)}
321+
ref={inputRef}
322+
tabIndex={disabled ? -1 : 0}
323+
/>
324+
);
313325
}
314326

315327
return null;
@@ -395,7 +407,6 @@ export const TextField = forwardRef<TextFieldForwardRef, TextFieldProps>((props,
395407
onKeyDown={onKeyDown}
396408
onKeyUp={onKeyUp}
397409
onClick={onClick}
398-
tabIndex={disabled ? -1 : 0}
399410
ref={innerRef}
400411
>
401412
{renderInputElement}

0 commit comments

Comments
 (0)