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

customfields: allow hidding section name #248

Merged

Conversation

jrcastro2
Copy link
Contributor

@jrcastro2 jrcastro2 force-pushed the allow-hide-accordion-custom-fields branch from a3ed259 to 0c47819 Compare July 31, 2024 11:01
const { fields, paths, section: sectionName = "" } = section;

return sectionName === "" ? (
<Container key={`section-${sectionName}`}>{fields}</Container>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather have config key e.g visible, hide to control this... With the current solution the key also is wrong as the sectionName is an empty string no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm that's was my first thought and I started by doing that but then I realised that if we don't add the section it will display wronlgy, like bugged accordion, and since when we hide it, the section name is not used at all I thought that it could help to fix the bug and simplify the logic. If section name is empty the key will be simply section-, it's not wrong simply a generic key. If you think there is added value to use the config key, I can add it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't thinking of the flag show or hide the accordion but rather just being used as part of your condition check i.e instead of if sectionName === ''

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I am missing something, that is exactly what is used to show or hide the accordion, feel free to reach out if you think it might be faser to discuss IRL!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have another question: why was this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In CDS we want to add the custom fields (experiment and department) inside the basic information section, meaning that they are not part of their own section, we need to be able to add fields without section

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would then try to find some other solution for this, because passing the section as empty string seems like a temporary workaround that should not make it inside the code. Can we do a demo?

</AccordionField>
))}
sections.map((section) => {
const { fields, paths, section: sectionName = "" } = section;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what Zach might be suggesting is

Suggested change
const { fields, paths, section: sectionName = "" } = section;
const { fields, paths, section: sectionName, hidden = False } = section;

I also think comparison with empty string to determine if the section is supposed to be displayed is not intuitive

@jrcastro2 jrcastro2 force-pushed the allow-hide-accordion-custom-fields branch 2 times, most recently from 1cb72f8 to 4af4470 Compare August 1, 2024 13:19
@jrcastro2 jrcastro2 force-pushed the allow-hide-accordion-custom-fields branch from 4af4470 to dab23e8 Compare August 1, 2024 13:20
@kpsherva kpsherva merged commit d930557 into inveniosoftware:master Aug 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSPN: vocabularies
3 participants