Skip to content

Commit

Permalink
TextWidgetRefactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishasoumya-02 committed May 17, 2024
1 parent ce35f82 commit eef894e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/volto/src/components/manage/Widgets/TextWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const TextWidget = (props) => {
onBlur,
onClick,
icon,
focus,
iconAction,
minLength,
maxLength,
Expand All @@ -29,11 +28,9 @@ const TextWidget = (props) => {

const ref = useRef(null);

useEffect(() => {
if (focus) {
ref.current.focus();
}
}, [focus]);
useEffect((focus) => {
if (focus) ref.current.focus();
}, []);

return (
<FormFieldWrapper {...props} className="text">
Expand Down Expand Up @@ -69,12 +66,13 @@ export default TextWidget;
TextWidget.propTypes = {
id: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
value: PropTypes.string,
isDisabled: PropTypes.bool,
onChange: PropTypes.func,
description: PropTypes.string,
required: PropTypes.bool,
error: PropTypes.arrayOf(PropTypes.string),
focus: PropTypes.bool,
onBlur: PropTypes.func,
onClick: PropTypes.func,
onEdit: PropTypes.func,
onDelete: PropTypes.func,
icon: PropTypes.shape({
xmlns: PropTypes.string,
viewBox: PropTypes.string,
Expand All @@ -88,12 +86,17 @@ TextWidget.propTypes = {
};

TextWidget.defaultProps = {
description: null,
required: false,
error: [],
value: null,
onChange: () => {},
onBlur: () => {},
onClick: () => {},
icon: null,
onEdit: null,
onDelete: null,
focus: false,
icon: null,
iconAction: null,
minLength: null,
maxLength: null,
Expand Down

0 comments on commit eef894e

Please sign in to comment.