Skip to content

Commit

Permalink
accordion can be folded on load
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducica committed May 9, 2024
1 parent 3d07ef8 commit fa98384
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/lib/forms/AccordionField.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class AccordionField extends Component {
];

const errorClass = hasError ? "error secondary" : "";
const [activeIndex, setActiveIndex] = useState(0);
const [activeIndex, setActiveIndex] = useState(active ? 0 : -1);

const handleTitleClick = (e, { index }) => {
setActiveIndex(activeIndex === index ? -1 : index);
Expand Down Expand Up @@ -100,14 +100,14 @@ export class AccordionField extends Component {
AccordionField.propTypes = {
active: PropTypes.bool,
includesPaths: PropTypes.array,
label: PropTypes.string,
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
optimized: PropTypes.bool,
children: PropTypes.node,
ui: PropTypes.object,
};

AccordionField.defaultProps = {
active: false,
active: true,
includesPaths: [],
label: "",
optimized: false,
Expand Down
6 changes: 5 additions & 1 deletion src/lib/forms/ArrayField.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ export class ArrayField extends Component {
} = props;
const {
addButtonLabel,
addButtonClassName,
children,
defaultNewValue,
fieldPath,
label,
labelIcon,
helpText,
requiredOptions,
showEmptyValue,
...uiProps
} = this.props;
const hasError = this.hasGroupErrors(errors) ? { error: {} } : {};
Expand Down Expand Up @@ -116,7 +118,7 @@ export class ArrayField extends Component {
<Form.Button
type="button"
icon
className="align-self-end mt-15"
className={addButtonClassName ?? "align-self-end mt-15"}
labelPosition="left"
onClick={() => {
arrayHelpers.push({
Expand Down Expand Up @@ -149,6 +151,7 @@ export class ArrayField extends Component {

ArrayField.propTypes = {
addButtonLabel: PropTypes.string,
addButtonClassName: PropTypes.string,
children: PropTypes.func.isRequired,
defaultNewValue: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
fieldPath: PropTypes.string.isRequired,
Expand All @@ -161,6 +164,7 @@ ArrayField.propTypes = {

ArrayField.defaultProps = {
addButtonLabel: "Add new row",
addButtonClassName: undefined,
helpText: "",
label: "",
labelIcon: "",
Expand Down

0 comments on commit fa98384

Please sign in to comment.