Skip to content

Commit c7ba540

Browse files
sabrina-bongiovannipnicolli
authored andcommitted
feat(a11y): porting of volto-form-block autocomplete changes (#779)
* feat: porting of volto-form-block autocomplete changes * fix: minor fixes
1 parent c1941f0 commit c7ba540

File tree

3 files changed

+353
-0
lines changed

3 files changed

+353
-0
lines changed

src/components/TextInput.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default function TextInput(props) {
1717
groupClassName,
1818
...otherProps
1919
} = props;
20+
2021
const [isFocused, setIsFocused] = useState(false);
2122

2223
const toggleFocusLabel = () => {

src/customizations/volto-form-block/components/Field.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const Field = ({
6464
errorMessage,
6565
id,
6666
reactSelect,
67+
autocomplete,
6768
}) => {
6869
const intl = useIntl();
6970
const Select = reactSelect.default;
@@ -102,6 +103,7 @@ const Field = ({
102103
onChange(name, e.target.value);
103104
}}
104105
value={value ?? ''}
106+
autoComplete={autocomplete}
105107
/>
106108
)}
107109
{field_type === 'textarea' && (
@@ -120,6 +122,7 @@ const Field = ({
120122
onChange(name, e.target.value);
121123
}}
122124
value={value ?? undefined}
125+
autoComplete={autocomplete}
123126
/>
124127
)}
125128
{field_type === 'select' && (
@@ -151,6 +154,7 @@ const Field = ({
151154
classNamePrefix="react-select"
152155
className={isInvalid() ? 'is-invalid' : ''}
153156
value={value ? [{ value: value, label: value }] : []}
157+
autoComplete={autocomplete}
154158
/>
155159
{description && <small className="form-text">{description}</small>}
156160
{errorMessage && (
@@ -286,6 +290,7 @@ const Field = ({
286290
onChange(name, e.target.value);
287291
}}
288292
value={value ?? ''}
293+
autoComplete={autocomplete}
289294
/>
290295
)}
291296
{field_type === 'attachment' && (
@@ -320,6 +325,7 @@ const Field = ({
320325
onChange(name, e.target.value);
321326
}}
322327
value={value ?? ''}
328+
autoComplete={autocomplete}
323329
/>
324330
)}
325331
{field_type === 'static_text' &&
@@ -382,6 +388,7 @@ Field.propTypes = {
382388
value: PropTypes.any,
383389
formHasErrors: PropTypes.bool,
384390
onChange: PropTypes.func,
391+
autoComplete: PropTypes.string,
385392
};
386393

387394
export default injectLazyLibs('reactSelect')(Field);

0 commit comments

Comments
 (0)