Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accordion can be folded on load #239

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Ducica marked this conversation as resolved.
Show resolved Hide resolved
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,
Ducica marked this conversation as resolved.
Show resolved Hide resolved
...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}
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: "align-self-end mt-15",
helpText: "",
label: "",
labelIcon: "",
Expand Down
Loading