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

fix checkbox visibility #92

Merged
merged 1 commit into from
Sep 5, 2024
Merged

Conversation

shiplet
Copy link
Contributor

@shiplet shiplet commented Sep 5, 2024

We're passing visibility as a prop into the BooleanControl component but not doing anything with it as relates to visibility of the rendered checkbox. This leads to unexpected behaviors when modifying visibility rules in downstream applications.

This PR adds the same props.visible check that's seen in other control elements.

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.70%. Comparing base (41724d5) to head (a042f9e).
Report is 3 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/controls/BooleanControl.tsx 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #92      +/-   ##
==========================================
- Coverage   74.85%   74.70%   -0.15%     
==========================================
  Files          38       38              
  Lines         501      502       +1     
  Branches       93       94       +1     
==========================================
  Hits          375      375              
  Misses         90       90              
- Partials       36       37       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shiplet shiplet force-pushed the b/_/fix-checkbox-visibility-handler branch from 637a4b0 to a042f9e Compare September 5, 2024 18:37
@@ -19,6 +19,8 @@ export function BooleanControl({
config,
description,
}: ControlProps) {
if (!visible) return null
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a subtle but important distinction between display:none and visibility:hidden CSS when it comes to forms. The former unmounts from the DOM completely whereas the latter keeps the element present and available to maintain form state. It looks like antd has a hidden prop on Form.Item to support the latter.

Does it make sense for this visibility prop to act like display:none?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@shiplet shiplet Sep 5, 2024

Choose a reason for hiding this comment

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

I think in the case of a JSONForms Control we want the item fully removed from the DOM because if it's not visible, then the implication is its values shouldn't be evaluated or included in the form payload.

This also follows the existing pattern we've established with other visibility-affected Control components.

@shiplet shiplet merged commit 6f852f8 into main Sep 5, 2024
2 of 5 checks passed
@shiplet shiplet deleted the b/_/fix-checkbox-visibility-handler branch September 5, 2024 19:42
Copy link

🎉 This PR is included in version 1.21.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants