Forms: conditional logic (3/5) — apply in the browser - #50978
Open
enejb wants to merge 1 commit into
Open
Conversation
This was referenced Jul 31, 2026
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Wire the resolver into the front-end form so fields appear and disappear as the visitor answers, and skip hidden fields when validating. Visibility is memoised per form rather than globally: two forms on one page have their own rules and answers, and a single shared cache let one form's result satisfy the other's lookup. Hidden fields use `display: none` as the base state, so a visitor with JavaScript or animations off still gets the right form. The reveal animation is additive, scoped to conditional fields, and inside `@media not (prefers-reduced-motion)`. Checkbox normalisation keys off the control's actual type rather than the field's declared one, so a consent field -- which renders as a checkbox but declares 'consent' -- no longer reads as checked after the visitor unchecks it. The context is also reconciled from the DOM on a bfcache restore, since neither input nor change fires when the browser puts the visitor's values back, and focus moves to the nearest visible control when the field being filled in is hidden by a cascade.
enejb
force-pushed
the
add/forms-conditional-logic-resolver
branch
from
August 4, 2026 18:36
c43767f to
0cc8354
Compare
enejb
force-pushed
the
add/forms-conditional-logic-frontend
branch
from
August 4, 2026 18:36
5a56544 to
cf7083a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Part 3 of 5 splitting #50938. Wires the resolver into the front-end form so fields appear and disappear as the visitor answers, and skips hidden fields when validating.
display: noneas the base state, so a visitor with JavaScript or animations off still gets a correct form. The reveal animation is purely additive, scoped to conditional fields, and inside@media not (prefers-reduced-motion).Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
The server does not stamp conditional markup until part 4, so the easiest way to exercise this alone is the unit tests:
jetpack test js packages/forms—conditional-visibility.test.jscovers the cascade, the per-form isolation, and the hidden-field validation skip.For a live check, enable the flag and use a form whose fields already carry
data-jp-conditional(or wait for part 4, which emits it):